java传输代码 java上传代码( 四 )


String fileName = in.readUTF(); //取得附带的文件名
if(filepath.endsWith("/") == falsefilepath.endsWith("\\") == false){
filepath += "\\";
}
filepath += fileName;
//4、将数据流写到文件中
writer = new DataOutputStream(new BufferedOutputStream(new BufferedOutputStream(new FileOutputStream(new File(filepath)))));
int bufferSize = 2048;
byte[] buf = new byte[bufferSize];
int read = 0;
while((read=in.read(buf)) != -1){
writer.write(buf, 0, read);
}
writer.flush();
System.out.println("数据接收完毕");
}catch(IOException ex){
ex.printStackTrace();
}finally{
try{
in.close();
writer.close();
client.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
}
java 引用传递代码19public static void fun(Message temp){
20temp.setNum (200) ;
21}
自定义对象 , 传递参数时,是传“址”的。。。。。。。。。。
16fun(msg) ;就是调用静态函数 fun、并传递参数msg————
关于java传输代码和java上传代码的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读