wood burning stoves 2.0
The moose likes I/O and Streams and the fly likes FTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FTP" Watch "FTP" New topic


Tirthankar Dutta Chaudhuri
Ranch Hand

Joined: Feb 26, 2005
Posts: 48
Can amy one help with java implementation of ftp . ( A java class that can ftp files .) i need the source code .
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32636

Welcome to JavaRanch!

This JavaWorld article describes how to FTP in Java.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ishrayansh Nath
Ranch Hand

Joined: Nov 05, 2004
Posts: 45
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

this is good package for FTP (commons-net-1.3.0.jar,jakarta-oro.jar)

Thanks & regards
Joe Ess

Joined: Oct 29, 2001
Posts: 9154

The package Shiryans is talking about can be found here

[How To Ask Questions On JavaRanch]
Ishrayansh Nath
Ranch Hand

Joined: Nov 05, 2004
Posts: 45
import org.apache.commons.net.ftp.FTPClient;
import java.net.*;
import java.io.*;
import java.lang.reflect.Array;

class newftp
public static void main(String[] args) throws java.net.MalformedURLException,java.net.UnknownHostException,java.io.IOException,java.io.FileNotFoundException
System.out.println("Hello World!");

FTPClient ftpClient = new FTPClient();
String host ="";
String userid="ftptest";
String pwd="ftptest";
System.out.println("Ftp is connected ");

URL hp = new URL("");

InputStream ip = hp.openStream();
System.out.println("Ftp is connected thro URL ");

// Make destination file
FileOutputStream dest = new java.io.FileOutputStream("F:\\folder1");

byte[] buf =(byte[])Array.newInstance(java.lang.Byte.TYPE,8192);

int byteCount;

while ( (byteCount = ip.read(buf)) > 0 )
catch(Exception e)

Jeff Grant
Ranch Hand

Joined: Dec 19, 2001
Posts: 169
I used FTP from JScape, it was very simple.
I agree. Here's the link: http://aspose.com/file-tools
subject: FTP
It's not a secret anymore!