文件从Windows操作系统转换为Java中的unix

1 java ftp cross-platform

我在运行时创建了一个pdf文件(在Windows操作系统中).我需要将它复制到另一个位置,它可能在UNIX或Windows上.有没有我可以用它做的java类?如何?谢谢.

Moh*_*igh 5

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)