Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

FTP  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can amy one help with java implementation of ftp . ( A java class that can ftp files .) i need the source code .
 
author & internet detective
Marshal
Posts: 38504
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tirthankar,
Welcome to JavaRanch!

This JavaWorld article describes how to FTP in Java.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9509
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The package Shiryans is talking about can be found here
 
Ishrayansh Nath
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}

}
}
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used FTP from JScape, it was very simple.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!