Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java FTP文件表示已上载,但未显示在服务器上_Java_File_Upload_Ftp - Fatal编程技术网

Java FTP文件表示已上载,但未显示在服务器上

Java FTP文件表示已上载,但未显示在服务器上,java,file,upload,ftp,Java,File,Upload,Ftp,我正试图创建一个文件,并将其从程序写入FTP文件服务器。.getReply()方法给出 “226文件已成功传输。” 尽管如此,大约95%的时间该文件不会显示在服务器上。它偶尔会起作用,但很少起作用。我无法确定它何时上传和何时不上传的具体趋势 try{ String userName = ""; FTPClient client = new FTPClient(); client.connect("host", 21); boolean login = clien

我正试图创建一个文件,并将其从程序写入
FTP
文件服务器。
.getReply()
方法给出

“226文件已成功传输。”

尽管如此,大约95%的时间该文件不会显示在服务器上。它偶尔会起作用,但很少起作用。我无法确定它何时上传和何时不上传的具体趋势

try{
    String userName = "";

    FTPClient client = new FTPClient();
    client.connect("host", 21);
    boolean login = client.login("username", "password");
    client.enterLocalPassiveMode();
    client.setFileType(FTP.BINARY_FILE_TYPE);

    String remoteFile = "/scores/";  
    BufferedReader read = new BufferedReader(new FileReader(file));
    userName = read.readLine();
    File localStore = new File(dir + "\\results\\" + userName + ".txt");
    localStore.getParentFile();
    localStore.createNewFile();
    FileWriter write = new FileWriter(localStore);
    String br = "BREAK";
    write.write(cpuName);
    write.write(br);
    write.write(CPUs);
    write.write(br);
    write.write(gpuName + " x" + gpuAmt);
    write.write(br);
    write.write(mbInfo);
    write.write(br);
    write.write(os);
    write.write(br);
    write.write(finalScore);
    write.close();
    if (login){
        String userdetail = "/scores/" + userName + ".txt";
        System.out.println(userName);
        InputStream input = new FileInputStream(localStore);
        boolean a = client.storeFile(userdetail, input);
        this.sleep(5000);
        System.out.println(client.getReplyString());
        input.close();
        client.logout();    
        client.disconnect();
    }
}catch (Exception err){}

我非常感谢您的帮助。

在您的捕获中,您什么都不是。至少添加代码以记录抛出异常时发生的情况


可能抛出了异常,但您不知道。

这应该是注释否,因为这是解决问题的方法。因此,这是一个答案。经过多次尝试后,不会抛出任何异常。