麻烦帮看段代码
public static void sendFile2Server(File local_file, String targeFile,String server, int port, String id) {
Socket socket = null;
InputStream iis = null;
OutputStream os = null;
try {
socket = new Socket(server, port);
byte[] fileNameBuf = targeFile.getBytes("GBK");
int fls = fileNameBuf.length;
byte[] fileNamelen = new byte[] { 0, 0, 0, 0 };
fileNamelen[0] = (byte) ((fls >> 24) & 0xff);
fileNamelen[1] = (byte) ((fls >> 16) & 0xff);
fileNamelen[2] = (byte) ((fls >> 8) & 0xff);
fileNamelen[3] = (byte) ((fls >> 0) & 0xff);
os = socket.getOutputStream();
os.write(SEND_HEADER);
os.write(fileNamelen);
os.write(fileNameBuf);
os.flush();
iis = new FileInputStream(local_file);
byte[] buf = new byte[1024];
int rl = iis.read(buf);
while (rl > 0) {
os.write(buf, 0, rl);
rl = iis.read(buf);
}
FileTransferStauts.statusMap.put(id, "finished");
} catch (Exception e) {
FileTransferStauts.statusMap.put(id, e.getMessage());
} finally {
try {
if (os != null)
os.close();
if (socket != null && !socket.isClosed())
socket.close();
if (iis != null)
iis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
红色的部分,对filename的操作有什么作用?