A java.io.File object is a representation of a file on a locally-mounted filesystem. It cannot be used to represent a remote file. Please don't ask "but what if...?" because the answer is still no.

The only way to get a listing of the files on an HTTP server is to ask the HTTP server for it; you'll only get a listing if the server allows it. In other words, you can use, e.g., URLConnection to to a GET request to the server with the URL of the "directory"; the server may return a page that lists the files. That's the absolute best you can do.

The ftp protocol (or its illegitimate cousin, sftp) are better suited for what you're trying to do.

File can only be used to access files on the local file system (and Windows shares and mounted (Samba / SMB / NFS) shares). Anything else, especially files you need to access using HTTP or FTP, are not supported by java.io.File.

If you need to access a file on one of those, you should check the java.net package instead. URL is especially useful - with its openConnection you get a URLConnection object which can give you an InputStream to read from.

As for determining whether or not something is a file, the answer is simple: you can't with the basic Java API. For folders on FTP it can be done (using Apache Commons Net or JvFTP), but HTTP files are even harder. Since for the client http://markmail.org/message/2q3cywpmdpjjkm4l could be both a file (located in folder message) or a folder itself (redirecting to http://markmail.org/message/2q3cywpmdpjjkm4l/index.html for instance), it will be (virtually) impossible to determine this information. And I haven't even mentioned URL rewriting!