Help Please

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

  1. cbtshare

    cbtshare

    Joined:
    Jul 17, 2006
    Messages:
    2
    Likes Received:
    0
    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 (Text):


    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. Advertisements

  2. cbtshare

    cbtshare

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

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,208
    Jeff C
    Jul 8, 2004
  2. Gandu
    Replies:
    0
    Views:
    1,245
    Gandu
    Jan 8, 2004
  3. Ayeda

    Please Please Help!!

    Ayeda, Jan 10, 2004, in forum: Java
    Replies:
    9
    Views:
    477
    Ayeda
    Jan 13, 2004
  4. casioculture@gmail.com
    Replies:
    4
    Views:
    829
    Chris Uppal
    May 5, 2005
  5. KK
    Replies:
    2
    Views:
    1,061
    Big Brian
    Oct 14, 2003
  6. MuZZy
    Replies:
    7
    Views:
    2,094
    Mike Hewson
    Jan 7, 2005
  7. mera
    Replies:
    7
    Views:
    1,358
  8. beth

    HELP HELP PLEASE HELP

    beth, Oct 27, 2005, in forum: Ruby
    Replies:
    1
    Views:
    168
    Sean O'Halpin
    Oct 27, 2005
Loading...