devxlogo

Reading Files with FTP

Reading Files with FTP

Question:
I want to create an applcation that reads a file from a host on my LAN. The file must be read by FTP. How do I do this?

Answer:
If all you need to do is retrieve a single file by FTP, the easiest way to do this is to use the URL and URLConnection classes, referencing the file FTP-style URL (e.g., ftp://ftp.java-pro.com/). If you need to list directories and check file sizes, however, a dedicated FTP package might be more in line. The code for these alternatives is already listed in other questions, so I won’t repeat it here. Take a look at the questions titled “Fetch contents of URL” to see how to use the URL class and “FTP with Java” to see how to use a dedicated FTP package. Both questions are in the Networking section of the Java section of the inquiry.com Web site.

See also  How College Students Can Shape the Future of Tech Responsibility
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist