JFileChooser jfc=new JFileChooser();
jfc.setSelectedFile(new File(jfc.getCurrentDirectory().getAbsolutePath(),name));
jfc.showSaveDialog(frame);
File f=jfc.getSelectedFile();
f.createNewFile();
dis=new DataInputStream(scoket.getInputStream());
RandomAccessFile raf=new RandomAccessFile(f,"rw");
byte[] buf=new byte[2048];
int num=0;
while((num=dis.read(buf))!=(-1))
{
raf.write(buf,0,num);
raf.skipBytes(num);
}
br.close();
dis.close();
raf.close();
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/lz12366007/archive/2009/10/28/4740238.aspx
jfc.setSelectedFile(new File(jfc.getCurrentDirectory().getAbsolutePath(),name));
jfc.showSaveDialog(frame);
File f=jfc.getSelectedFile();
f.createNewFile();
dis=new DataInputStream(scoket.getInputStream());
RandomAccessFile raf=new RandomAccessFile(f,"rw");
byte[] buf=new byte[2048];
int num=0;
while((num=dis.read(buf))!=(-1))
{
raf.write(buf,0,num);
raf.skipBytes(num);
}
br.close();
dis.close();
raf.close();
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/lz12366007/archive/2009/10/28/4740238.aspx