I cannot find an example of simple FTP access to a file anywhere, and the FTPClient class (which is used in several examples) does not appear in the Android class index. I have http access, but how do I make simple FTP access? All I want to do is download (for example):
ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/KABQ.TXT
It should not contain a login, change directory, etc. Just giving this URL to http access methods does not work.
This seems like a question:
could not read the file with ftp in android?
I tried simply:
StringBuilder response = new StringBuilder();
URLConnection ftpConn;
try {
URL netUrl = new URL("ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/KABQ.TXT");
ftpConn = netUrl.openConnection();
BufferedInputStream bufRd = new BufferedInputStream(ftpConn.getInputStream());
int temp;
while ((temp = bufRd.read()) != -1) {
response.append(temp);
}
bufRd.close();
} catch (Exception e) {
return "Failure";
}
but it gets an exception in getInputStream: Unable to connect to server: cannot configure data port
, , , ? .
, HTTP, FTP-, URLConnection ? HttpConnection http URLConnection ftp?
!