Hi I try connect and upload file to ftp. code:
import java.net.*;
import java.io.*;
import java.security.*;
/**
*
* @author mars
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try{
URL url = new URL("ftp://login:pass@host/");
URLConnection con = url.openConnection();
BufferedInputStream in = new BufferedInputStream(con.getInputStream());
FileOutputStream out = new FileOutputStream("c:/file.zip");
System.out.print("url");
int i = 0;
byte[] bytesIn = new byte[1024];
while ((i = in.read(bytesIn)) >= 0) {
out.write(bytesIn, 0, i);
}
out.close();
in.close();
}
catch(IOException e){System.out.print(e.toString());}
}
}
and in window Output in Netbeans I have this code but nothing in my ftp. Why?
init:
deps-jar:
compile:
run:
url
BUILD SUCCESSFUL (total time: 8 seconds)