为null那里只给了文件名啊,服务端的路径呢?
解决方案 »
- 在struts2的action中使用axis调用webservice出错
- cvs网上怎么从别人的电脑上把项目拿下来
- 烦恼,大家帮忙分析一下,到底是怎么回事啊
- 刚学程序设计,关于利用MVC模式开发Java应用程序,想不通的,请指教!
- 关于在validator中使用javascript过程中javascript不起作用的问题
- spring+ibatis的问题!
- 实体BEAN的一个问题??急!!
- java面试题 大家头脑风暴下!
- 有没有一个OR Mapping自动生成类的工具,不要整套的解决方案,只要一个自动类生成的工具。
- Error configuring application listener of class org.springframework.web.context.
- jsp中截取获取的内容
- Red Hat解析 excel 2007格式异常
public void connectServer(String ip, int port, String userName,
String userPwd, String path) {
ftpClient = new FTPClient();
try {
// 连接
ftpClient.connect(ip, port);
// 登录
ftpClient.login(userName, userPwd);
if (path != null && path.length() > 0) {
// 跳转到指定目录
ftpClient.changeWorkingDirectory(path);
}
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FTPClient fclient = new FTPClient();
fclient.connect("127.0.0.1", 21); fclient.login("root", "root");
System.out.println(fclient.isConnected());
fclient.changeWorkingDirectory(null);
fclient.setBufferSize(1024);
fclient.setFileType(FTP.BINARY_FILE_TYPE);
FileOutputStream fileOutputStream = new FileOutputStream("c:\\a.txt");
InputStream ins = null;
ins = fclient.retrieveFileStream("20141201.txt");
if (null != ins) {
System.out.println("===========");
byte[] b = new byte[ins.available()];
while ((ins.read(b)) != -1) {
fileOutputStream.write(b);
}
fileOutputStream.close();
ins.close();
fclient.getReply();
}
} catch (Exception e) {
e.printStackTrace();
}