• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
Posts: 38917
686
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: 9550
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!