Help Please

Discussion in 'Java' started by cbtshare, Nov 13, 2007.

  1. cbtshare

    cbtshare

    Joined:
    Jul 17, 2006
    Messages:
    2
    Hey wats up guys, I have a text file that stores database of clients names and bank info, I entered the info into an array but dont kn0w how to run a query based on user input?? help please this is my code
    Code:
    
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.*;
    import java.util.*;
     
     
    public class WordReader {
    public static void main( String[] args ) {
      String Bebe;
      
        PrintStream output = System.out;
        Scanner input = new Scanner(System.in);
    // will store the words read from the file
    List<String> wordList = new ArrayList<String>();
     
    BufferedReader br = null;
    try {
    // attempt to open the words file
    br = new BufferedReader( new FileReader( "a2.txt" ) );
     
    String word;
     
    // loop and read a line from the file as long as we dont get null
     
    while( ( word = br.readLine() ) != null )
    // add the read word to the wordList
    wordList.add( word );
    } catch( IOException e ) {
    e.printStackTrace();
    } finally {
    try {
    // attempt the close the file
    br.close();
    } catch( IOException ex ) {
    ex.printStackTrace();
    }
    }
     
    // initialize a new string array equal to the size of thewordList
     
    String[] words = new String[ wordList.size() ];
     
    // call the wordList's toArray method to and transfer itemsfrom
     
    // wordList to our string array words
    wordList.toArray( words );
     
     
     
    // loop and display each word from the words array
    for( int i = 0; i<words.length; i++)
    {
     
    output.println(words[i]);
     
    }
     
     
     
    }
    }
    
     
    cbtshare, Nov 13, 2007
    #1
    1. Advertising

  2. cbtshare

    cbtshare

    Joined:
    Jul 17, 2006
    Messages:
    2
    or is this the best way?
     
    cbtshare, Nov 13, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JC
    Replies:
    4
    Views:
    8,019
    Jeff C
    Jul 8, 2004
  2. casioculture@gmail.com
    Replies:
    4
    Views:
    552
    Chris Uppal
    May 5, 2005
  3. KK
    Replies:
    2
    Views:
    665
    Big Brian
    Oct 14, 2003
  4. MuZZy
    Replies:
    7
    Views:
    1,801
    Mike Hewson
    Jan 7, 2005
  5. mera
    Replies:
    7
    Views:
    1,143
Loading...

Share This Page