ok then I'll prefer using this. Could tell me how I can implement tokens onto web links? because currently my codes are working fine except for the last part. I'm need ing it to be able to download all files automatically but now it appears to only be able to download only one file. I have tokenized the downloaded entry files and retrieved the tokens for the entry names but when i tried putting in the token it only appears to download only one file. Why is that so? the code is listed above. so sorry for the hassle

it only appears to download only one file

There must be something wrong in your loop that it only executes one time.
Add some println() statements to the loop to show why it is exiting the loop after the first file is downloaded.

I've taken the last part and put it aafter this loop

while(s.hasMoreTokens()) {
      String ss = s.nextToken();
      counter++;
      if (counter == 1 ) // extracts only 1st tokens per line.
      System.out.print(ss + "\n");
 	
 		
      }

and the SS variable cannot be found. if I were to put the downloading part into the while loop, it only downloads one file.

input = new BufferedReader(
      new FileReader( new File("C:\\Users\\Royston\\Documents\\FTP downloads\\pdb.txt") ) );
      String text;
      while ( ( text = input.readLine() ) != null ) {
      StringTokenizer s = new StringTokenizer(text,"	");
      int counter=0;
      while(s.hasMoreTokens()) {
      String ss = s.nextToken();
      counter++;
      if (counter == 1 ) // extracts only 1st tokens per line.
      System.out.print(ss + "\n");

this is the part without the last downloading of all the files i need. This part tokenizes and outputs the file names I want to download. without the downloading part, it outputs all the names one after another, however after I add in the downloading part, it only outputs 1 file and downloads one file.

You need to put the filenames into a collection or an array so you can use them in a loop.

logic in pseudo code after the names are in an array: filesList[]

For example:

loop thru contents of filesList[]
  get next filename from the list
  get that file via FTP and save it to disk
end loop

ss contains all the filename but i've tried putting it into array but it says incompatible type.

You must copy and paste the full text of error messages here if you need help.

i've taken out the download part and trying to store it into an array but i receive this error:

String[] filesList = ss;

incompatible types

/**
 * @(#)filename.java
 *
 *
 * @author 
 * @version 1.00 2010/7/26
 */
import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.io.FileOutputStream;
import java.io.*;
import java.util.*;

public class filename {
 public static StringBuffer buffer;
 public static BufferedReader input;
    public static void main(String[] args) {
    	
    	
    	      try{
      
      input = new BufferedReader(
      new FileReader( new File("C:\\Users\\Royston\\Documents\\FTP downloads\\pdb.txt") ) );
      String text;
      while ( ( text = input.readLine() ) != null ) {
      StringTokenizer s = new StringTokenizer(text,"	");
      int counter=0;
      while(s.hasMoreTokens()) {
      String ss = s.nextToken();
      counter++;
      if (counter == 1 ) // extracts only 1st tokens per line.
      System.out.print(ss + "\n");
 	
 	 String[] filesList = ss;

 		
      }
		

    }
      }catch( IOException ioException ) {} 
    	 	
    } 
}

incompatible types

What you posted was NOT the full text of the error message.
Please copy full text of error message and paste it here. Here is a sample:

TestSorts.java:138: cannot find symbol
symbol  : variable var
location: class TestSorts
         var = 2;
         ^

You need to study how to define and use arrays. This is very basic java programming.

the error i got was this..

C:\Users\Royston\Desktop\filename.java:39: incompatible types
found : java.lang.String
required: java.lang.String[]
String[] filesList = ss;
^
1 error

String[] filesList = ss;
What are you trying to do here?
The statement defines a String array variable named filesList
and then tries to assign to it a String variable.
The compile doesn't know what to do when the variable on one side of the = sign is of different type than what is on the other side.
In your case one side is an array and the other is a String.

You need to study how to use arrays.
There are three steps:
Define a variable of the type you want: String[] asdf; // defines asdf to be an array of Strings
Create an array object: asdf = new String[10]; // create an array of 10 elements
Assign values to the elements of the array: asdf[ix] = "A string"; // set element at ix to a String

I've tried it but im experiencing these errors:

String[] filesList;
		 int j =0;
		 filesList = new String[100000];
		 filesList [j]= ss;
		 for(int z =0; z<filesList.length; z++)
 			System.out.println( filesList[j] + "\n");

here is the error:

--------------------Configuration: <Default>--------------------
C:\Users\Royston\Desktop\filename.java:40: '.class' expected
         String[] filesList;
                  ^
C:\Users\Royston\Desktop\filename.java:40: not a statement
         String[] filesList;
               ^
2 errors

Process completed.

Please show lines 1 to 40 of your program. The compiler is confused by what you have on line 40. Its probably because of what precedes line 40.

The array has been created, but the output is only showing one file name instead of all the file names. below are the codes

import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.io.FileOutputStream;
import java.io.*;
import java.util.*;

public class filename {
 public static StringBuffer buffer;
 public static BufferedReader input;
    public static void main(String[] args) {
    	
    	
    	      try{
      
      input = new BufferedReader(
      new FileReader( new File("C:\\Users\\Royston\\Documents\\FTP downloads\\pdb.txt") ) );
      String text;
      while ( ( text = input.readLine() ) != null ) {
      StringTokenizer s = new StringTokenizer(text,"	");
      int counter=0;
      while(s.hasMoreTokens()) {
      String ss = s.nextToken();
      counter++;
      if (counter == 1 ) // extracts only 1st tokens per line.
      {
      
 	     
 	     int j =0;
 	     String[] filesList;
 	     filesList = new String[100000];
		 filesList [j]= ;
		 for(int z =0; z<filesList.length; z++)
 			System.out.println( filesList[j] + "\n");
      }
      }
		

    }
      }catch( IOException ioException ) {} 
    	 	
    } 
}

Hi Norm. Thanks for your help once again. Everything's working fine now. Managed to make it work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.