fout = new RandomAccessFile(file,"rw");
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}
Socket dataSocket=null;
try {
cmdoutput.println("canwrite");//文件创建成功
dataSocket = serverSocket.accept();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
try{
fout.close();
}catch (IOException e) {
e.printStackTrace();
}
return;
}
DataInputStream din=null;
try {
din = new DataInputStream(new BufferedInputStream(dataSocket.getInputStream()));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
try{
fout.close();
dataSocket.close();
}catch (IOException e) {
e.printStackTrace();
}
}
byte[] buf=new byte[2048];
int num;
try{
while(!dataSocket.isInputShutdown() && (num=din.read(buf))!= -1){
fout.write(buf,0,num);
}
}catch (IOException e)
{
e.printStackTrace();
System.out.println("读输入流错误");
}
|