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 java.net.*;
import java.io.*;
public class FTPTest
{
public static void main(String [] arstring)
{
String user = "myFTPuser";
String password = "myFTPpassword";
String host = "myFTPhost";
String file = "myFTPfile";
String userInfo = user + ":" + password;
String urlString = "ftp://" + userInfo + "@" + host + "/" + file + ";type=i";
int bufferSize = 1024;
try{
URL url = new URL(urlString);
URLConnection urlc = url.openConnection();
OutputStream os = urlc.getOutputStream();
BufferedOutputStream ost = new BufferedOutputStream(os, bufferSize);
FileInputStream ist = new FileInputStream(file);
byte[] buffer = new byte[bufferSize];
int nBytes;
while((nBytes = ist.read(buffer)) != -1)
{
ost.write(buffer, 0, nBytes);
ost.flush();
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
import sun.net.ftp.*;
import sun.net.TelnetInputStream;
public class FtpExample {
public FtpExample() {
}
private void doIt() {
String server = "ftp.microsoft.com";
String user = "me";
String passwd = "1234";
try {
FtpClient client = new FtpClient();
client.openServer(server);
client.login(user, passwd);
client.binary();
client.cd("MISC");
TelnetInputStream in = client.get("ReadMe1.txt");//now do whatever u want with this inputstream
System.out.println("ReadMe1 = " + in.toString());
in.close();
client.closeServer();
} catch (java.io.IOException e) {
}
}
public static void main(String[] args) {
FtpExample example = new FtpExample();
example.doIt();
}
}