diminuta
diminuta

Reputation: 1583

FtpOutputStream or similar in standard Java

is there any possible way to write a file to a FTP directory using some sort of OutputStream without having to write a local file first?

I've found some 3rd party libraries which achieve this, but I was wondering if there is some java "standard" class that makes it possible, I mean, some class that is packaged into the standar Java API.

Thank you!!

Upvotes: 1

Views: 2681

Answers (2)

Taky
Taky

Reputation: 5344

  • If you should only write/read files is better to use java.net.URL class.
  • If seems you should manipulate files/directories via FTP you must use 3rd party library.

The best practice is building abstract layer to not depend from FTP solution.

As for me the best tool for Java FTP is http://www.sauronsoftware.it/projects/ftp4j/

Upvotes: 2

urir
urir

Reputation: 2025

URL url = new URL("ftp://user:[email protected]/file.txt;type=i");
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // To download
OutputStream os = urlc.getOutputStream(); // To upload

Upvotes: 5

Related Questions