I'm trying to access a file through URL connection to a ftp server. The code I have used to retrieve the file and read is:
URL ftpurl = new URL("ftp://username:password@xxx.xxx.xxx.xxx/home/appuser/LoginCheck/cpuLive.log");
URLConnection connection = ftpurl.openConnection();
connection.connect();
InputStream input = new BufferedInputStream(ftpurl.openStream());
System.out.println(input);
But i'm getting a FileNotFound exception:
Exception in thread "main" java.io.FileNotFoundException: home/appuser/LoginCheck/cpuLive.log
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at com.djblogin.codes.ProcessAll.processLogin(ProcessAll.java:413)
at com.djblogin.codes.ProcessAll.processOperations(ProcessAll.java:39)
at com.djblogin.codes.LoginCheck.main(LoginCheck.java:14)
When I give the same URL in browser i can retrieve the file. Please help.