当前位置: 代码迷 >> J2SE >> ftpclient 乱码有关问题 如何解决
  详细解决方案

ftpclient 乱码有关问题 如何解决

热度:2682   发布时间:2013-02-25 00:00:00.0
ftpclient 乱码问题 怎么解决?
 
用的是APACHE的FTPCLIENT, 但文件名中如果有中文, 传到服务器上就乱码了, 
尝试过ftpClient.setControlEncoding("gb2312"); “UTF-8”,"GBK"
都不行, 弄了一半天, 不知道有什么办法吗


 public boolean upload(String path, String fileName, InputStream inputStream) throws IOException {
  boolean flag = false;
  try {
  ftpClient.setControlEncoding("gb2312");
  FTPClientConfig conf = new FTPClientConfig(FTPClientConfig.SYST_UNIX);
  conf.setServerLanguageCode("en");
  ftpClient.cwd(remotePath);
  alertWorkingDirectory(path);
  flag = ftpClient.storeFile(new String(fileName.getBytes("utf-8"), "gb2312"), inputStream);
  if (flag) {
  System.out.println(" upload success !!! ");
  }
  // ftpClient.sendCommand("chmod 777 " +fileName);
  } catch (IOException e) {
  logger.severe("not upload !!! " +e.getMessage());
  throw new IOException(e);
  }
  return flag;
  }

------解决方案--------------------------------------------------------
在客户端转码试试