Home Tutorialhelp Comment help fo ftp

 
 

Comment

yare
help fo ftp,
January 13, 2008 at 8:29 AM

Hi I have a problem with my ftp, my code is not working. i may made mistake somehow, if some one can helping me pease. The code is like this.
import java.io.*;
import java.net.*;
import java.util.*;

public class Ass_2 {
public static void main(String[] args){
String currentPath = new String(); currentPath = "ftp://ftp.scit.wlv.ac.uk/pub";
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str,user,pass ;
System.out.println("\n\nTYPE HELP for view the list of commands and there Formats!!");
System.out.println("enter command 'bye' to exit the application");
System.out.print("Enter Username: ");
user = in.readLine();
System.out.print("Enter Password: ");
pass = in.readLine();
String tempPath = new String();
String toFile = new String();
tempPath = currentPath ;
readPage(currentPath);
while (!(str = in.readLine()).equals("bye")){
int tokencount;
StringTokenizer token = new StringTokenizer(str);
tokencount = token.countTokens();
String block[] = new String[tokencount];
for (int i = 0; i < tokencount; i++)
{
block[i] = token.nextToken();
System.out.println(block[i]);
}
if (block[0].equalsIgnoreCase("dir")){
System.out.println("DIR");
System.out.println(currentPath);
readPage(currentPath);
System.out.println("\n");
}else if(block[0].equalsIgnoreCase("cwd")){
System.out.println("Change Directory");
currentPath = changeDirectory(currentPath, block[1]);
System.out.println("\n");
}else if(block[0].equalsIgnoreCase("get")){
System.out.println("Wait Copying File : "+block[1]);
copyFile(currentPath,block[1]);
}else if(block[0].equalsIgnoreCase("cd..")){
currentPath = goBack(currentPath);
}else if(block[0].equalsIgnoreCase("help")){
System.out.println("\nYour in the Help Section \n");
}else {
System.out.println("Wrong Command or Format, Type Help!!!");
System.out.println("\n");
}
}
}
catch(Exception e){
System.out.println(e);
}
}

// Function to read content form the specfied path
static void readPage(String path){
String tempPath = new String();
try {
URL pageref = new URL(path);
InputStream in = pageref.openStream();
BufferedReader inline = new BufferedReader(new InputStreamReader(in));//(instr);
String line;
int linect = 0;
while((line = inline.readLine())!=null){
linect++;
System.out.println(line);
}
System.out.println("lines read = "+linect);
}
catch(Exception e){
System.out.println(e);
}
}
static String changeDirectory(String path,String dir){
path = path+"/"+dir;//System.out.println(">>>>>>>>>>> " +path+" >>> \n");
readPage(path);

return path;
}
// Function to go one setp back from the current directory
static String goBack(String currentPath){
return currentPath;
}
/// Function for basic copy TXT file
static void copyFile(String path,String file){
try {
path = path +"/"+ file; //System.out.println("Copy Path : " + path);
String fileName = new String();
fileName = file+".txt";
System.out.println("Out put file name : " + fileName);
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(fileName));
URL pageref = new URL(path);
InputStream in = pageref.openStream();
BufferedReader inline = new BufferedReader(new InputStreamReader(in));//(instr);
String line;
int linect = 0;
while((line = inline.readLine())!=null){
System.out.println(line);
linect++; //System.out.println(line);
out.write(line+"\r\n");
}
out.close();
System.out.println("File - " +file+ " - copyed Successfully !!");
}
catch(Exception e){
System.out.println(e);
}
}
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Tools

FTP Server : Create Directory
In this section you will learn how to create directory on FTP server using java 

Java Beginners

how to copy the directory in to ftp server using java
how to copy the directory in to ftp server using java  how to copy the directory in to ftp server using java ?   Hello venaktehs As much as I know,You can do this as follows: First,Create a directory in the current 

Java-Tutorials

FTP Programming in Java tutorials with example code
continuing with the FTP Programming in Java. With the help of these tutorials... will learn how to create program in Java that connects to FTP server and upload... and Login FTP Server : Create Directory FTP Server 

Java Beginners

io
io  create a meanu based text editor in java having features of creating file,viewing file,deleting file,renaming file,copying file and cutting file 

Programming Tutorials

File IO
The Java IO package is used to perform various input/output processing activities.In this section we are giving overview of java IOJava io classes... are planning to learn file management using Java IO package.This class is available 

Java Beginners

java io
java io  by using java coding how to invoke a particular directory 

Java Tools

FTP Server : Remove Directory
In this section you will learn how to delete directory on FTP server using java 

Java-Tutorials

Java Create Directory Example
Java Create Directory Example To create a directory in java call the mkdir..., to many directories in directory you need to call the mkdirs() mehtod. An example of creating a directory in java is given below SampleInterfaceImp.java import 

Programming Tutorials

Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
 File(path)  Create File object for default directory...;Create File object for directory path given as string.  File(dir, fname)  Create File object for directory. Thus 

Java Beginners

Java FTP
: Connect and Login FTP Programming in Java tutorials with example code Thanks  ...Java FTP  Hi, Is there any API for using FTP in java? Can anyone share me the sample Java FTP code? Thanks   Hi, There are many FTP 

Java Beginners

Java FTP Example
Java FTP Example  Is there any java ftp example and tutorials... and tutorials that teaches you how to user FTP in your Java project. Most commonly used FTP api in java is Apache FTP. Browse all the FTP tutorials at Java FTP 

Java Beginners

Java FTP Client Example
Java FTP Client Example  How to write Java FTP Client Example code? Thanks   Hi, Here is the example code of simple FTP client in Java which downloads image from server FTP Download file example. Thanks 

Java Beginners

FTP Java example
FTP Java example  Where is the FTP Java example on your website? I am searching on the internet and found your website. I have to add the FTP... examples of FTP at: FTP Programming in Java tutorials with example code. Thaks 

Java Beginners

java binary file io example
java binary file io example  java binary file io example 

Java Beginners

io
io  write a program in java to accept a filename from user and print its content on the monitor   Hello Friend, Try the following code: import java.io.*; import java.util.*; class DisplayContentOfFile { public 

Java Beginners

hi... pls give me the example of java coding fo following question
hi... pls give me the example of java coding fo following question  example java coding that reads in the radius and length of cylinder and computes volume. formula: Area = radius * radius * PI Volume = area * length 

Java Beginners

FTP Java coading
help me to solve this The import org.apache.oro cannot be resolved   Hi, Please check example code at Java FTP tutorials page. Thanks...FTP Java coading  I am struggling to solve a FTP issue. FTPFile 

Java Beginners

FTP with Java
tutorials at FTP Programming in Java tutorials with example code. Thanks...FTP with Java  How to FTP with Java code? Usually you can find any windows client on internet. You can use FTP software to upload and download files 

Java Beginners

hi... pls give me the example of java coding fo following question
hi... pls give me the example of java coding fo following question  Write a java program that reads the following information and prints a payroll statement: Employee??s name (e.g: Sam) Number of hours worked in a week (e.g: 10 

Java Beginners

How to implement FTP using java
want to implement FTP using Java to transfer files and exchange files between FTP client and FTP server. Could anyone help me for How to implement FTP using java... is the best tutorials and example of Apache FTP Library: FTP Programming in Java 

Java Beginners

Java FTP file upload example
Java FTP file upload example  Where I can find Java FTP file upload example? What is the link of the FTP examples on your website? Thanks   Hi, We have many examples of Java FTP file upload. We are using Apache 

Java-Tutorials

Java IO Path
Java IO Path In this section we will discuss about the Java IO Path. Storage of a file or folder(Directory/Subdirectory) in a Hard Drive or other media.... These sub folders can contains a file or sub folders and so on. For example 

Java Tools

FTP Server : Change working directory
In this tutorial you will learn how to change working directory on FTP server using java 

Java Tools

Change parent directory on ftp server
In this section you will learn how to change the parent directory on FTP server using java 

Java Beginners

IO File - Java Beginners
IO File  Write a java program which will read an input file & will produce an output file which will extract errors & warnings. It shall exclude... from the log file. This is the task assigned to me..Please help me 

Java Beginners

Import java IO - Java Beginners
Import java IO  for example i know java IO is for input and output. I am using Netbeans5.5.1. How can i see all the classes related to java IO for example; stream reader, buffer reader 

Core Java

Java Create Directory
The following example will show how to Create Directory in Java. Though... is already created" will be displayed. Example of Java Create Directory... of the program. For this we cerate a file object in File class which will create a new 

Java Beginners

Simple FTP upload in Java
Simple FTP upload in Java  How to write a program for Simple FTP upload in Java? Any code example of Simple FTP upload in Java will be very helpful for me. Thanks 

Java Beginners

java io - Java Beginners
Java IO Streams  What is the Java IO Stream 

Java Beginners

Java FTP Upload
Java FTP Upload  Is there any example code for Java FTP Upload? Which is the easy to use Java FTP Upload example program at roseindia.net? Thanks... in Java. View the FTP Server : Upload file example for complete code example 

Java Beginners

Java upload file to ftp
. View complete example at FTP File Upload in Java Thanks...Java upload file to ftp  Hi, How to uploaded file to a ftp server in Java? Thanks   Hi, It's very easy to write a program in Java 

Java Beginners

Java FTP Connection
Java FTP Connection  I am learning to develop a program in Java... if it works? How to make Java FTP Connection to FTP server hosted in my network? Thanks   See the example code at FTP Server : Connect and Login 

Java Beginners

Java Connect to and FTP Server
Java Connect to and FTP Server  What is the code for Java Connect to and FTP Server? How to establish a connection to FTP server in Java? Thansk... the apache commons library to connect/login to FTP server. Link of complete example 

Java Beginners

Java FTP Download
Java FTP Download  How to write a program in Java for downloading a file from FTP server? Tell me the good and easy to understand code for Java FTP... the complete example at FTP Server : Download file. Thanks 

Java Interview Questions

Java IO
Java IO  What an I/O filter 

Java Beginners

java IO
java IO  Write a Java program to accept a file name as command line argument. Append the string "File Modified by Programme" to the end of the same file and print the contents of the modified File 

General

Java FTP Library
Java FTP Library        The Java Ftp Library Let's imagine a situation... for a quality Java FTP client library that matches our needs is not as simple 

Java Tools

Search Directory on Ftp Server
This tutorial describes how to search a specific directory on the server by using java 

Java Beginners

java io
java io  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits 

Java Technology Tutorials

FTP File Upload in Java
will be able to create programs in Java that uploads the file on FTP server...FTP File Upload in Java This tutorial shows you how you can write Java program... easy to write code for FTP File Upload in Java. I am assuming that you have FTP 

Java Beginners

Directory chooser in core java - Java Beginners
Directory chooser in core java  Hi, I have to create a Utility... to create a GUI( AWT or Swing based only) which should have 2 directory...[]) { JFrame frame = new JFrame("Directory chooser file example"); FileChooser 

Java Beginners

Getting Current Directory from java - Java Beginners
://www.roseindia.net/java/java-get-example/get-CWD.shtml http://www.roseindia.net/java/example/java/io/GetCurrentDir.shtml Thanks... in linux where i need to get the current directory of my java file... I'm using 

Java Beginners

Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help 

Java Beginners

io packages - Java Beginners
io packages  How can I add two integers in java using io pacages 

Java Technology Tutorials

Java file new directory
Java file new directory In this section, you will learn how to create a new... an object of File class and specify a directory which you want to create. Then we..."); file.mkdir(); } } By using the method mkdir(), you can create a directory 

Java Beginners

Simple IO Application - Java Beginners
Simple IO Application  Hi, please help me Write a simple Java application that prompts the user for their first name and then their last name. The application should then respond with 'Hello first & last name, what 

Programming Tutorials

How to make directory in java
Description: This example demonstrate how to create a directory at specified path. Code: import java.io.File; public ... is that it will make a dir at root directory of C drive 

Java Beginners

java IO programing
java IO programing  how Java source file is used as input the program will echo lines 

Java Tools

Checking Directory existence on Ftp Server
In this section, you will learn how to check existence of a directory on the server by using java 

Java Beginners

java-io - Java Beginners
java-io  Hi Deepak; down core java io using class in myn...://www.roseindia.net/java/java-conversion/two-dimensional-array-program-using-nested-loop.shtml http://www.roseindia.net/java/beginners/SquareMatrix.shtml Thanks 

Java-Tutorials

Java Create Directory - Java Tutorial
Java Create Directory - Java Tutorial   ...;java CreateDirectory Directory: test created Directories...;. the mkdir( ) method is used to create a single directory while the mkdirs( ) method 

Java Beginners

Image uploading in FTP Server
Image uploading in FTP Server  I want to upload images to a ftp server every 1 hour automatically using java..please help 

Java-Tutorials

Java IO OutputStreamWriter
"); bw.newLine(); bw.write("Java IO OutputStreamWriter Example...Java IO OutputStreamWriter In this section we will learn about the Java..."); osw = new OutputStreamWriter(os); osw.write("Java IO 

Java Tips and Examples

Java Create Directory - Java Tutorial
Java Create Directory - Java Tutorial       In the section of Java Tutorial you will learn how to create directory using java program. This program also explains 

Java Beginners

connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import... client = new FTPClient(); client.connect("ftp://111.111.111.111 

Java Beginners

connect ftp from java program
connect ftp from java program  Hi, I need to connect to the ftp and get the files through a java program.. I wrote the following code... import... client = new FTPClient(); client.connect("ftp://111.111.111.111 

Java Beginners

Implementing FTP in Java Code
Implementing FTP in Java Code  Hi, My job is to write a program in Java in my project. I have to implement FTP in my Java Code. Share me some of the code of Implementing FTP in Java Code. Thanks   Hi, Apache ftp 

Java Beginners

Java FTP jar
Java FTP jar  Which Java FTP jar should be used in Java program for uploading files on FTP server? Thanks   Hi, You should use commons-net-3.2.jar in your java project. Read more at FTP File Upload in Java 

Java-Tutorials

Java Io BufferedWriter
Java IO BufferedWriter In this section we will discuss about the BufferedWriter class in Java. java.io.BufferedWriter class extends the java.io.Writer class.... Constructors of this class provides the facility to create a default size buffer 

Java Beginners

How to create a new text file that contains the file names of the copied files in a new directory? - Java Beginners
How to create a new text file that contains the file names of the copied files in a new directory?  Okay so my question is: How to create a new text file that contains the file names of the copied files in a new directory 

Java Beginners

IO concept
IO concept  Write a java program that moves the contents of the one file to another and deletes the old file.   Hi Friend, Try...!"); } } For more information, visit the following link: Java Move File Thanks 

Java-Tutorials

Java IO FilterWriter
Java IO FilterWriter In this example we will discuss about the FilterWriter...(); bw.write("Java IO FilterWriter Example"); System.out.println("Data is written... an example is being given which demonstrates about how to use Java FilterWriter 

Java Beginners

Java FTP Tutorial
Java FTP Tutorial  I am new to FTP programming in Java. I have lots... and password of the FTP server. Now I have to learn FTP programming in Java fast to develop our project. Is there any good Java FTP Tutorials? Thanks 

Java Beginners

Java FTP Library
Java FTP Library  Which all Java FTP Library available in market? Is there any free open source Java FTP Library? Thanks   Hi, Both open source and commercial Java FTP library are available on Internet. Most used open 

Java Beginners

Java FTP Client
Java FTP Client  What all Java FTP Client available to the Java... commons-net library is open source robust library in Java. It also contains FTP... Downloading Deleting Moving files Don't forgot to see Java FTP examples 

Java Beginners

FTP server
FTP server  How to store a series of files in a ftp server using java 

Java-Tutorials

Java IO CharArrayWriter
Java IO CharArrayWriter In this tutorial we will learn about the CharArrayWriter in Java. java.io.CharArrayWriter extends the java.io.Writer.... constructor is used to create a new CharArrayWriter. Syntax : public CharArrayWriter 

Java-Tutorials

Traversing a file and directory under a directory
and subdirectories are traversed lying under a directory. We can find that, how many files and directories are available within a directory. This is very frequently... describes how you can traverse a directory if it contains directory and files 

Java Beginners

Java ftp commons
Java ftp commons  From should I download the Java ftp commons library. Thanks   Hi, Java ftp commons is actually Apache commons library... in Java for more information on how to use apache commons java ftp library 

Java-Tutorials

Copy Directory or File in Java
Copy Directory in Java      ... the features of the copying the directory and it's contents. This example shows.... otherwise read the source directory name and create the OutputStream instance 

Java Beginners

File copy from one directory to another in java
very good code example for copying a file from one directory to another directory in Java. I have to write a program in my application for copying one file... in Java which will help in writing code for copy the file in just few lines of code 

Java Beginners

ftp - Java Beginners
ftp  pls tell me how to connect to a ftp server and copy a file to local machine using java, with UNIX code for copying purpose 

Java Beginners

FTP Server
FTP Server  i'm working on ftp server if one client has uploaded a file i need to save the details of the user who has uploaded the file like username,filename & ipaddress using java 

Java Beginners

io - Java Beginners
. http://www.roseindia.net/java/ Thanks Amardeep 

PHP Questions

Create Directory in PHP
Create Directory in PHP  Hi, I want to create a small php program like how to create directory in PHP. I need the help of PHP programmer, who could... here with suggest the best examples and syntax related how to create directory 

Java-Tutorials

Directory and File Listing Example in Java
C:\nisha>java DirListing example myfile.txt... specified a directory name "example" that contains only a single file "myfile.txt". Download this example Example 

Java Beginners

How to upload file on FTP Server
is good and can be used in Java applications. Read FTP File Upload in Java for more...How to upload file on FTP Server  In my application there is a requirement of uploading the file on FTP server. How to upload file on FTP Server 

Java Beginners

core java ,io operation,calling methods using switch cases
core java ,io operation,calling methods using switch cases  How to create a dictionary program,providing user inputs using io operations with switch cases and providing different options for searching,editing,storing meanings 

Java3D Questions

help in java
help in java  Create a class named Order that performs order... the instance variables values and the result of the computePrice() method. Create... toString() This is an example on a valid output of the program: Please enter 

Java3D Questions

help in java
help in java   Team Roster Create a program called TeamRoster... or help me on this pleas.. 7. Gross And Dozens Design and implement a class..., and how many left over eggs he has. For example, if the user says that he has 1342 

Java3D Questions

help in java
help in java  Create 3 shopping carts from a Cart class. Each class should have four items in it, a title, a price for the 4 items and the number...) and n!=1 (for n=0) for example, 5!=5.4.3.2.1, which is 120 a) Write 

Java Tips and Examples

Java Directory - Directory and File Listing Example in Java
Java Directory - Directory and File Listing Example in Java...; This example illustrates how to list files and folders present in the specified directory. This topic is related to the I/O (input/output 

Java-Tutorials

Moving file or directory from one directory to another
from one directory to another. In this section an example is given... name and if you enter "y", it will create a new directory... directory does not exist. \nDo you want to create a new directory(Y/N)? " 

Java-Tutorials

Java IO File
Java IO File In this section we will discuss about the File class in Java... can also create a File to store the data. To create file in Java a class named... of this class a Java programmer can create a new file. File.createNewFile() method 

Java-Tutorials

Java IO StringReader
Java IO StringReader In this section we will discuss about the StringReader... in Java. In this example I have created a Java class named...; String str = "\n Java IO StringReader \n"; try 

Java Tools

FTPClient : List System Help
This section lists the help information provided by FTP server class in java 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Java Magazine Questions

how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code 

Programming Tutorials

Open Source Directory
Open Source Directory Open Source Java Directory The Open Source Java... - to many different platforms.    Open Source Java Directory The Open Source Java Directory is maintained by Steve Mallett, creator 

Ant

Ant make directory with relative path
;    This example illustrates how to make directory, how to compile java file and how to create jar file. This is a simple program...; is used to compile the java file and copy the class file in build directory 

Ajax Questions

upload files to apache ftp server - Ajax
upload files to apache ftp server  hi,sir I want to upload multiple files to apache ftp server. I am using ajax framework for j2ee.Now I am okay for my customize code for my ftp testing.But I want to upload and download to ftp 

Java-Tutorials

Java: Kilometer to Miles - IO Class
Java NotesKilometer to Miles - IO Class 1 2 3 4 5 6.... double miles; // Number of miles. IOHandler io; //... Initialization io = new IOHandler 

Java Beginners

why to create directory structure as web-inf & classes & lib - Java Beginners
why to create directory structure as web-inf & classes & lib    we all know that to prepare webapplications we will create a direcotry sturcture... e)providing deployment descriptor (web.xml) as part of WEB-INF directory 

Java Beginners

why to create directory structure as web-inf & classes & lib - Java Beginners
why to create directory structure as web-inf & classes & lib    we all know that to prepare webapplications we will create a direcotry sturcture... e)providing deployment descriptor (web.xml) as part of WEB-INF directory 

Advertisements Advertisements
 

 

 

DMCA.com