我做了一个小I机器人,当我的MSN向小I机器人发送文件的时候,MSN提示版本过旧,不能传送文件,现在我又不能重新装一个新版本的MSN,我要在当前版本上面实现可以传送文件,哪位仁兄知道怎么样改代码呀?
解决方案 »
- struts实现文件上传下载
- 刚入职新的公司分了一个非常紧的项目(求一个思路 不是技术)
- 上传图片,重启tomcat图片就不见了。
- 急!急!急!Oracle CLOB 读取出错!
- 在jdk6.0+Eclipse3.2+MyEclipse的JSF开发环境中下列语句出现错误
- 如何配置数据库
- 为什么j2ee.jar会与servlet-api.jar有冲突?
- 求助 为什么找不到 ejb这个包?
- Could not roll back Hibernate transaction
- 做Java开发,应该有什么样的职业规划呢?
- SSH错误
- tomcat移植到resin上,出错!!!!『虚拟空间上跑struts2的项目能行吗??』
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 = ");
}
就是在这里面写接收文件的代码,并保存到本地路径