生成文本文件,通过FTP上传到服务器上,但发现上传后,文本丢失内容!请大家帮忙!

解决方案 »

  1.   

    String server=Config.getInstance().getConfigItem("UeSoftFtpServer");
    String user=Config.getInstance().getConfigItem("UeSoftFtpUser");
    String password=Config.getInstance().getConfigItem("UeSoftFtpPass");
    String path=Config.getInstance().getConfigItem(model+"_response");
    String filename=billFiledir + billFileName;
    System.out.println("filename = "+filename);
    try {
       FtpClient ftpClient=new FtpClient();
       ftpClient.openServer(server);
       ftpClient.login(user, password);
       System.out.println("====="+ftpClient.pwd() + "/" +model + "/response/");
       ftpClient.cd(ftpClient.pwd() + "/" +model + "/response/");
       ftpClient.binary();
       TelnetOutputStream os=ftpClient.put(billFileName);
       File file_in=new File(filename);
       FileInputStream is=new FileInputStream(file_in);
       byte[] bytes=new byte[1024];
       int c;
       while ((c=is.read(bytes))!=-1){
           os.write(bytes,0,c);}
       is.close();
       os.close();
       ftpClient.closeServer();
    } catch (IOException ex) {
      System.out.println("ex=="+ex);
    }这是代码