aspose file tools*
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
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FTP" Watch "FTP" New topic
Author

FTP

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Tirthankar,
Welcome to JavaRanch!

This JavaWorld article describes how to FTP in Java.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

The package Shiryans is talking about can be found here


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[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 ="192.168.5.70";
String userid="ftptest";
String pwd="ftptest";
ftpClient.connect(host);
ftpClient.login(userid,pwd);
System.out.println("Ftp is connected ");


URL hp = new URL("ftp://192.168.5.70//folder1");

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


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

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

int byteCount;

while ( (byteCount = ip.read(buf)) > 0 )
{
dest.write(buf,0,byteCount);
}
dest.close();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}
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