|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
ftp
how can i incoroporate ftp functions into my java code?
I tried searching at sun but found nothing i would use the basic functions rather then using a set of functions someone else has developed cheers |
|
#2
|
|||
|
|||
|
What kind of functions do you want? Downloading a file from an ftp server isn't too complicated.
First create a URL object and give the protocol, host and a filename (you could use a different constructor if you wish): URL url = new URL("ftp", "ftp.foo.com", "/pub/file.txt"); Now you can connect to the server: URLConnection conn = url.openConnection(); conn.connect(); To read data from the file, get an input stream: InputStream in = conn.getInputStream(); This next bit will print the contents to standard output (only good if it's a plain text file): BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line; while ((line = br.readLine()) != null) { System.out.println(line); } |
|
#3
|
|||
|
|||
|
As ross has pointed out downloading from an FTP server isn't difficult at all. Same goes for uploading. Unfortunately if you want more than that you need to find an FTP library there are several available (shameless plug: including our own free library).
__________________
A lean and mean secure FTP applet with GUI. Just 150 kb in size http://www.radinks.com/sftp |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > ftp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|