package ogloszenia.klient;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class Klient01_URL {

	public static void main(String[] args) {
		
		try {
			URL url = new URL("http://localhost:8080/pc_rest3_ogloszenia-1.0/ogloszenia.json");
			try(InputStream input = url.openStream()) {
				long ileBajtow = Files.copy(input, Paths.get("dane01.json"), StandardCopyOption.REPLACE_EXISTING);
				System.out.println("Gotowe. Skopiowano " + ileBajtow + " bajtów.");
			}
		
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
