📌  相关文章
📜  如何从服务器 url 中提取图像并将其存储在 java 代码示例中的文件夹中

📅  最后修改于: 2022-03-11 14:52:14.505000             🧑  作者: Mango

代码示例1
try (BufferedInputStream inputStream = new BufferedInputStream(new URL("http://example.com/my-file-path.txt").openStream());
  FileOutputStream fileOS = new FileOutputStream("/Users/username/Documents/file_name.txt")) {
    byte data[] = new byte[1024];
    int byteContent;
    while ((byteContent = inputStream.read(data, 0, 1024)) != -1) {
        fileOS.write(data, 0, byteContent);
    }
} catch (IOException e) {
    // handles IO exceptions
}