我在运行时创建了一个pdf文件(在Windows操作系统中).我需要将它复制到另一个位置,它可能在UNIX或Windows上.有没有我可以用它做的java类?如何?谢谢.
URL url =
new URL("ftp://username:password@ftp.localhost/file.pdf;type=i");
URLConnection con = url.openConnection();
BufferedInputStream in =
new BufferedInputStream(con.getInputStream());
FileOutputStream out =
new FileOutputStream("C:\\file.pdf");
int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = in.read(bytesIn)) >= 0) {
out.write(bytesIn, 0, i);
}
out.close();
in.close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4044 次 |
| 最近记录: |