ftp文件传输,数据部分丢失~~~~~ 我从数据库中取出数据来,写到xml文件中 ,通过ftp上传到某服务器,不知道咋回事,我本地的xml文件大小总是比上传上去的文件大,也就是会丢失一部分内容,这种情况是偶尔发生的,也就是说,有的时候是能上传成功的!!!!!!!!!!!我很郁闷阿,咋回事呢?5555555555555555555555 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用什么传的, 格式相同吗? 都是DOS ,或者都是UNIX? 格式应该无所谓还是ftp上传的类写的有问题吧应该是已上传文件大小<=要上传的文件大小的时候就继续传贴个代码看看清晰些 这是我的代码~~~~~嘿嘿!!private String SendFile(String pathName,String fileName) { FtpClient aftp; TelnetInputStream ins; TelnetOutputStream outs; DataOutputStream outputs; try { aftp = new FtpClient("123.22.12.218"); aftp.login("1", "1"); aftp.binary(); aftp.cd("/"); //showFileContents(); if(aftp != null) { int ch=1000; RandomAccessFile sendFile = new RandomAccessFile(pathName, "r"); sendFile.seek(0L); outs = aftp.put(fileName); outputs = new DataOutputStream(outs); for(; sendFile.getFilePointer() < sendFile.length(); outputs.write(ch)) { ch = sendFile.read(); } outs.close(); sendFile.close(); } return "yes"; }catch(Exception ex) { return ex.toString(); } } 代码没看出有问题,不行就直接读字节吧 ftpClient.binary(); File file = new File("src\\com\\example\\test\\TestFtp.java"); System.out.println(file.getAbsolutePath()); tos = ftpClient.put("testaaa.txt"); InputStream is = new FileInputStream(file); int len1 = (int) file.length(); int len2 = 0; int len3 = 0; byte[] b = new byte[1024]; while (len2 < len1) { len3 = len1 - len2; if (len3 >= 1024) { is.read(b); tos.write(b); len3 = 1024; } else { is.read(b, 0, len3); tos.write(b, 0, len3); } len2 += len3; } is.close(); tos.close(); 急急!!求教高手POI读取Excel问题 HQL查询的简单问题求教 conn.createStatement问题 myeclipse问题 希望能解决.... 谁有Javamail的收邮件的例子,要能够运行的。比如可以收pop3.163.com上的 菜鸟我提一个class和jsp文件摆放问题! 如何隐藏真实的URL? 如何能得到上传文件的个数! 怎么微软的对与sql2000的jdbc的lib里面三个文件是压缩的呢?好象不像以前的。 struts资源文件问题 怎么实现Excel文件的下载?
还是ftp上传的类写的有问题吧
应该是已上传文件大小<=要上传的文件大小的时候就继续传贴个代码看看清晰些
这是我的代码~~~~~嘿嘿!!
private String SendFile(String pathName,String fileName)
{
FtpClient aftp;
TelnetInputStream ins;
TelnetOutputStream outs;
DataOutputStream outputs;
try
{
aftp = new FtpClient("123.22.12.218");
aftp.login("1", "1");
aftp.binary();
aftp.cd("/");
//showFileContents();
if(aftp != null)
{
int ch=1000;
RandomAccessFile sendFile = new RandomAccessFile(pathName, "r");
sendFile.seek(0L);
outs = aftp.put(fileName);
outputs = new DataOutputStream(outs);
for(; sendFile.getFilePointer() < sendFile.length(); outputs.write(ch))
{
ch = sendFile.read();
}
outs.close();
sendFile.close(); } return "yes";
}catch(Exception ex)
{
return ex.toString();
}
}
File file = new File("src\\com\\example\\test\\TestFtp.java");
System.out.println(file.getAbsolutePath());
tos = ftpClient.put("testaaa.txt");
InputStream is = new FileInputStream(file);
int len1 = (int) file.length();
int len2 = 0;
int len3 = 0;
byte[] b = new byte[1024];
while (len2 < len1) {
len3 = len1 - len2;
if (len3 >= 1024) {
is.read(b);
tos.write(b);
len3 = 1024;
} else {
is.read(b, 0, len3);
tos.write(b, 0, len3);
}
len2 += len3;
}
is.close();
tos.close();