67,513
社区成员
发帖
与我相关
我的任务
分享
public void fileReceiveStarted(VolatileDownloader downloader) {
File f = downloader.getFile();
String name = f.getName();
String filePath = "C:\\filepath";
File myFile = new File(filePath);
if(!myFile.exists()) {
myFile.mkdir();
}
System.out.println("path = " + downloader.getFile().getPath());
System.out.println("name = " + downloader.getFile().getAbsolutePath());
try {
InputStream instream = new FileInputStream(f);
byte[] bytes = new byte[(int)f.length()];
instream.read(bytes);
OutputStream outstream = new FileOutputStream(filePath+"\\" + name);
BufferedOutputStream bs = new BufferedOutputStream(outstream);
bs.write(bytes);
instream.close();
outstream.close();
bs.close();
instream.close();
outstream.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
System.out.println("文件接收方法:fileReceiveStarted" + ":path = ");
}