/usr/share/doc/jftp/examples/FtpUpload.java is in jftp 1.52+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | import net.sf.jftp.net.ConnectionHandler;
import net.sf.jftp.net.ConnectionListener;
import net.sf.jftp.net.DataConnection;
import net.sf.jftp.net.FtpConnection;
import net.sf.jftp.net.BasicConnection;
import net.sf.jftp.system.logging.Log;
import net.sf.jftp.system.logging.Logger;
import net.sf.jftp.config.Settings;
import java.io.*;
/**
* See FtpDownload.java for comments.
*/
public class FtpUpload implements Logger, ConnectionListener
{
private boolean isThere = false;
private ConnectionHandler handler = new ConnectionHandler();
public FtpUpload(String host, String dir, String file)
{
Log.setLogger(this);
FtpConnection con = new FtpConnection(host);
con.addConnectionListener(this);
con.setConnectionHandler(handler);
con.login("anonymous","no@no.no");
while(!isThere)
{
try { Thread.sleep(10); }
catch(Exception ex) { ex.printStackTrace(); }
}
con.chdir(dir);
con.upload(file);
}
public static void main(String argv[])
{
if(argv.length == 3)
{
FtpUpload f = new FtpUpload(argv[0], argv[2], argv[1]);
}
else
{
FtpUpload g =
new FtpUpload("upload.sourceforge.net", "/incoming", "test.txt");
}
}
public void updateRemoteDirectory(BasicConnection con)
{
System.out.println("new path is: " + con.getPWD());
}
public void connectionInitialized(BasicConnection con)
{
isThere = true;
}
public void updateProgress(String file, String type, long bytes) {}
public void connectionFailed(BasicConnection con, String why) {System.out.println("connection failed!");}
public void actionFinished(BasicConnection con) {}
public void debug(String msg) {System.out.println(msg);}
public void debugRaw(String msg) {System.out.print(msg);}
public void debug(String msg, Throwable throwable) {}
public void warn(String msg) {}
public void warn(String msg, Throwable throwable) {}
public void error(String msg) {}
public void error(String msg, Throwable throwable) {}
public void info(String msg) {}
public void info(String msg, Throwable throwable) {}
public void fatal(String msg) {}
public void fatal(String msg, Throwable throwable) {}
}
|