-2

Hi guys I'm using a java socket to send files I want to change the file name when it received to the server or client it will be like server-file.pdf and I'm using FileInputStream,BufferedInputStream,BufferedOutputStream.

4

1 回答 1

0

当您制作输出流时,您不能使用以下内容:

try {
    fos = new FileOutputStream("M:\\test2.xml");
    bos = new BufferedOutputStream(fos);

} catch (FileNotFoundException ex) {
    System.out.println("File not found. ");
}

而不是 test2,您可以将其命名为路径和名称。

来源,包括一个更完整的例子:

[1] Java 通过套接字发送和接收文件 (byte[])

于 2013-10-20T14:00:29.337 回答