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]);
}
}
}