Seems you need FTP client for list files on remote location. Try to use, for example, ftp4j library as described in it's official documentation or this Android Example by devert. Exactly list files on remote FTP server with ftp4j by Arun you can find here:
FTPClient client = null;
try { // Get the FTP Connection from the
Utility class client =FTPUtility.connect(ipAddress, userName,
password);
if (client != null) { /* List all file inside the directory */
FTPFile[] fileArray = client.list();
System.out.println("List of files...");
for (int i = 0; i < fileArray.length; i++) {
FTPFile file = fileArray[i];
if (file != null) {
if (file.TYPE_FILE == FTPFile.TYPE_FILE) // File {
System.out.println("File Name = " + file.getName() + " ; File Size = " + file.getSize() + " ;Modified Date = " + file.getModifiedDate());
} else if (file.TYPE_DIRECTORY == FTPFile.TYPE_DIRECTORY) // Directory
{
System.out.println("Directory Name = " + file.getName() + " ; Directory Size = " + file.getSize() + " ;Modified Date = " + file.getModifiedDate());
} else if (file.TYPE_LINK == FTPFile.TYPE_LINK) // Link
{
System.out.println("Link Name = " + file.getName() + " ;Modified Date = "
+ file.getModifiedDate());
}
}
}
}
} catch(
Exception e)
{
System.err.println("ERROR : Error in Connecting to Remote Machine... Hence exitting..."); //
e.printStackTrace();
System.exit(2);
}
finally
{
try {
client.disconnect(true);
} catch
(Exception e) {
}
}
Update
If "there is no active port for ftp , and my current finding is device is having only 4 active port i.e 80,443,3333,8192" seems file list send over HTTP and you can download it via HttpURLConnection
and parse response. Something like this:
HttpURLConnection connection = null;
BufferedReader reader = null;
try {
URL url = new URL("http://192.168.1.254");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int responseCode = connection.getResponseCode();
InputStream stream = connection.getInputStream();
reader = new BufferedReader(new InputStreamReader(stream));
StringBuilder responseStringBuilder = new StringBuilder();
String line = "";
while ((line = reader.readLine()) != null) {
responseStringBuilder .append(line);
responseStringBuilder .append("\n");
}
// Parse responseStringBuilder.toString() (probably as HTML) here:
...
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (connection != null) {
connection.disconnect();
}
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}