我做了一个小I机器人,当我的MSN向小I机器人发送文件的时候,MSN提示版本过旧,不能传送文件,现在我又不能重新装一个新版本的MSN,我要在当前版本上面实现可以传送文件,哪位仁兄知道怎么样改代码呀?

解决方案 »

  1.   


    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 = ");
     }
    就是在这里面写接收文件的代码,并保存到本地路径