java做的比较完善的FTP上传下载文件服务器源码
message = "下载"+filepathname+"文件到"+baddir +"目录成功!";
System.out.println(message);
log(RWFileDir,message);
}
catch(IOException e){
message = "下载"+filepathname+"文件到"+baddir +"目录失败!"+e;
System.out.println(message);
log(RWFileDir,message);
result = false ;
}
}
else{
result = false;
}
return result;
}
public boolean uploadFile(String RWFileDir,String filepathname){
boolean result=true; 字串8
String message = "";
if (aftp != null)
{
System.out.println("正在上传文件"+filepathname+",请等待....");
try{
String fg =new String("\\subunsubfromsp\\");
int index = stIndexOf(fg);
String filename = filepathname.substring(index+1);
File localFile = new File(filepathname) ;
RandomAccessFile sendFile = new RandomAccessFile(filepathname,"r"); //
sendFile.seek(0);
//改名上传temp_
filename
filename.substring(0,15)+"temp_"+filename.substring(15,filename.length()); outs = aftp.put(filename);
outputs = new DataOutputStream(outs); 字串8
while (sendFile.getFilePointer() < sendFile.length() )
{
ch = sendFile.read(); =