//获取本地文件下的图片
File folder = new File("E:\\picture");
File[] files = folder.listFiles();
String oldpic = files[0].getname();
//对图片进行重命名
InputStream is = null; // 从本地读取下载下来的文件输入流
OutputStream os = null;
try {
is = new FileInputStream("E:\\picture\\oldpic.jpg");
System.out.println(directory+historyDirectory);
File destFile = new File("E:\\picture\\history","newpic.jpg");
os = new FileOutputStream(destFile);
byte[] buffer = new byte[is.available()];
int length = 0 ;
while((length = is.read(buffer))>0){
os.write(buffer, 0, length);
}
is.close();
os.close();
flag="true";
} catch (Exception e) {
logger.error("图片转换失败"+e.getMessage());
e.printStackTrace();
try {
if(null != is){
is.close();
}
if(null != os){
os.close();
}
} catch (Exception e1) {
logger.error("关闭图片流失败"+e1.getMessage());
}
}
或者是
file.renameTo(destFile);
//读取ftp上的文件
private static FTPClient ftpclient = new FTPClient(); // 静态 FTPClient 对象
ftpclient.connect(ftpIp, Integer.parseInt(ftpPort));
ftpclient.login(ftpName, ftpPassword)
FTPFile[] ftpFiles =ftpclient.listFiles(ftpDirectory);
http://download.csdn.net/detail/lzy000000/5210304