Erstellen Sie eine text-Datei im FTP-server (Commons-net)

Ich brauche Hilfe mit Java Networking die Programmierung. Ich habe versucht, erstellen Sie eine neue text-Datei auf FTP-server. Ich fand das code-Beispiel im internet, aber es legt nur ein Verzeichnis.
Wie zu ändern, um text-Datei-format?

Hier der code:

public class FTPCreateDirDemo {
private static void showServerReply(FTPClient ftpClient) {
    String[] replies = ftpClient.getReplyStrings();
    if (replies != null && replies.length > 0) {
        for (String aReply : replies) {
            System.out.println("SERVER: " + aReply);
        }
    }
}
public static void main(String[] args) {
    String server = "www.yourserver.com";
    int port = 21;
    String user = "username";
    String pass = "password";
    FTPClient ftpClient = new FTPClient();
    try {
        ftpClient.connect(server, port);
        showServerReply(ftpClient);
        int replyCode = ftpClient.getReplyCode();
        if (!FTPReply.isPositiveCompletion(replyCode)) {
            System.out.println("Operation failed. Server reply code: " + replyCode);
            return;
        }
        boolean success = ftpClient.login(user, pass);
        showServerReply(ftpClient);
        if (!success) {
            System.out.println("Could not login to the server");
            return;
        }
        //Creates a directory
        String dirToCreate = "/upload123";
        success = ftpClient.makeDirectory(dirToCreate);
        showServerReply(ftpClient);
        if (success) {
            System.out.println("Successfully created directory: " + dirToCreate);
        } else {
            System.out.println("Failed to create directory. See server's reply.");
        }
        //logs out
        ftpClient.logout();
        ftpClient.disconnect();
    } catch (IOException ex) {
        System.out.println("Oops! Something wrong happened");
        ex.printStackTrace();
    }
}

Sorry für mein schlechtes Englisch.

InformationsquelleAutor Tadas | 2014-09-27
Schreibe einen Kommentar