Как загрузить файл на диск HQ
Exception in thread "main" java.net.ConnectException: Connection timed out: connect at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.<init>(Unknown Source) at java.net.Socket.<init>(Unknown Source) at org.apache.commons.net.DefaultSocketFactory.createSocket(DefaultSocketFactory.java:53) at org.apache.commons.net.SocketClient.connect(SocketClient.java:162) at org.apache.commons.net.SocketClient.connect(SocketClient.java:250) at JavaClassPak.FileUpload.upload(FileUpload.java:18) at JavaClassPak.FileUpload.main(FileUpload.java:55)
Что я уже пробовал:
package JavaClassPak; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.SocketException; import org.apache.commons.net.ftp.FTPClient; public class FileUpload { //String Ftp_Path = "ftp://173.201.0.1/"; //String Ftp_Path = "173.201.0.1"; FTPClient client = new FTPClient(); public boolean upload(File file) throws SocketException, IOException{ System.out.println("hello world"); client.enterLocalPassiveMode(); client.connect("www.ftp.drivehq.com"); // client.connect(Ftp_Path); client.login("EmailId", "Password"); client.enterLocalPassiveMode(); FileInputStream fis = new FileInputStream(file); boolean status = client.storeFile(" \\My Documents\\"+file.getName(), fis); client.logout(); fis.close(); return status; } public static void main(String[] args) throws SocketException, IOException { /*System.out.println("Hello My World Java "); InetAddress addr = InetAddress.getLocalHost(); //Getting IPAddress of localhost - getHostAddress return IP Address // in textual format String ipAddress = addr.getHostAddress(); System.out.println("IP address of localhost from Java Program: " + ipAddress); //Hostname String hostname = addr.getHostName(); System.out.println("Name of hostname : " + hostname); System.out.println(); System.out.println();*/ FileUpload obj=new FileUpload(); File file =new File("Helloooo.txt"); System.out.println(file.exists()); boolean b=obj.upload(file); System.out.println(b); /*Read more: http://javarevisited.blogspot.com/2012/09/java-program-to-find-ip-address-of.html#ixzz51IwudRt4 */ } }