import java.io.*;
import java.net.URL;
public class ImageDownloader {
public static void main(String[] args) {
String imageUrl = "твоя ссылка"; // URL of the image
String destinationFolder = "/path/to/destination/folder/"; // Destination folder on disk
try {
// Create URL object
URL url = new URL(imageUrl);
// Open a connection to the URL
InputStream inputStream = url.openStream();
// Create destination file
String[] urlParts = imageUrl.split("/");
String fileName = urlParts[urlParts.length - 1];
File destinationFile = new File(destinationFolder + fileName);
// Create FileOutputStream to write to the destination file
OutputStream outputStream = new FileOutputStream(destinationFile);
// Read from the input stream and write to the output stream
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
// Close streams
inputStream.close();
outputStream.close();
System.out.println("Image downloaded successfully to: " + destinationFile.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
}
мне просто лень самому это всё набивать... попросил жпт настрадать пару строк...
проверял... работает... только твою картинку я даже не пытался открывать или скачивать
Например есть такая картинка, как можно ее скачать в нужную папку?