Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import sun.net.ftp.*;
import sun.net.*;
import java.io.*;
public class Ftp {
public static void main(String args[]) throws Exception {
// Conatct server and log in
String server = "bridport";
String user = "joeblogs";String passwd = "abcdefg";//
FtpClient client = new FtpClient();
System.err.println("Opening server ...");
client.openServer(server);
System.err.println("Logging in...");
client.login(user, passwd);
System.err.println("Changing to binary ...");
client.binary();//
client.cd("transfer");
// pwd
String pwd = client.pwd();
System.err.println(pwd);
// list dir
TelnetInputStream in = client.list();
BufferedOutputStream bos = new BufferedOutputStream(System.err);
int buffer = 0;
while ((buffer = in.read()) != -1) {
bos.write(buffer);
}
bos.flush();
bos.close();
in.close();
// Get a file
in = client.get("floodmap.png");
bos = new BufferedOutputStream(new FileOutputStream("C:/floodmap2.png"));
buffer = 0;
while ((buffer = in.read()) != -1) {
bos.write(buffer);
}
bos.flush();
bos.close();
in.close();
// Send a file
TelnetOutputStream out = client.put("floodmap.png");
File file = new File("C:/floodmap.png");
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
byte[] b = new byte[(int)file.length()];
bis.read(b);
out.write(b);
out.flush();
out.close();
bis.close();
client.closeServer();
}
}