import java.io.*;
import java.net.*;
import sun.net.*;
import sun.net.ftp.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/public class FtpFile {
String FtpServer;
String FtpUser;
String FtpUserPwd;
String FtpPath;
String FtpOutPath; public FtpFile() {
getFtpConfig();
} /**读取Ftp配置*/
private synchronized int getFtpConfig(){
try{
FtpServer=Config.getProperty("FtpServer","182.67.5.98");
FtpUser=Config.getProperty("FtpUser","user");
FtpUserPwd=Config.getProperty("FtpUserPwd","1");
FtpPath=Config.getProperty("FtpPath","path");
FtpOutPath=Config.getProperty("FtpOut","d:\\ftp");
}
catch (Exception e){
return -1;
}
return 0;
} /**取得Ftp文件*/
public String getHostFile(String FileName){
String outFile=FtpOutPath+"\\"+FileName;
try{
FtpClient ftpClient=new FtpClient();
ftpClient.openServer(FtpServer); //连接FTP服务器
ftpClient.login(FtpUser, FtpUserPwd);
if (FtpPath.length()!=0)
ftpClient.cd(FtpPath);
ftpClient.binary();
TelnetInputStream is=ftpClient.get(FileName);
java.io.File file_out=new java.io.File(outFile);
java.io.FileOutputStream os=new java.io.FileOutputStream(file_out);
byte[] bytes=new byte[1024*600];
int c;
while ((c=is.read(bytes))!=-1) {
os.write(bytes,0,c);
}
is.close();
os.close();
ftpClient.closeServer();
}
catch(IOException e){
System.out.print("ERROR: 下载失败!");
e.printStackTrace();
}
return outFile;
}
}
怎么把一个文件分成若干快,然后再合并起来呢?