I am trying to read data from a file from ftp server. This piece of code works perfectly in java when i run from my desktop computer. I copied over the same code to android and i am getting an exception. The Exception is:
java.io.IOException: Unable to connect to server: Unable to retrieve file: 550
I have no idea why it is occurring when the same code is working perfecty in java. The java code is:
String s = "ftp://username:password@ftp.mysite.x10.mx:21/sg1996text.txt;type=i";
URL u;
String f="";
try {
u = new URL(s);
URLConnection uc=u.openConnection();
BufferedInputStream bis=new BufferedInputStream(uc.getInputStream()); //This is where exception i raised.
System.out.println("IS opened");
int i;
while((i=bis.read())!=-1)
f=f+(char)i;
System.out.println("File Read");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}