Hey everyone. I'm at the point where in this program I need to read a textfile and place the entries into a hashmap.
this is the txt example
1<>John Kane
2<>Jane Lyman
3<>Peter Hansen
4<>Cathy Harris
I've designed the main app which is the GUI. I have several text areas where I need to display the name only.
On a separate class I need to have it handle the I/O, with buffered reader and read each text files line by line and place them into a hashmap skipping the "<>." Then some how have it displayed in the text areas... can anyone help me out on this?
Comments
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader( new FileReader( "E:/test.txt" ));
String line = null;
Map result = new HashMap();
while( (line = reader.readLine()) != null ){
String[] arr = line.split( "<>" );
result.put( arr[0], arr[1] );
}
}
}
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader( new FileReader( "E:/test.txt" ));
String line = null;
Map result = new HashMap();
while( (line = reader.readLine()) != null ){
String[] arr = line.split( "<>" );
result.put( arr[0], arr[1] );
}
}
}