i am new to java, i have tried to read a file and saved into Hashmap. But it showing ArrayIndexBounds Of Exception.i dont know how to solve it.
here is my code,
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
public class excer4 {
public static void main(String[] args) throws Exception {
Map<String, String> map = new HashMap<String, String>();
BufferedReader in = new BufferedReader(new FileReader("/home/mansoor/Documents/exm.txt"));
String line = "";
while ((line = in.readLine()) != null) {
String parts[] = line.split("\t");
map.put(parts[0], parts[1]);
}
in.close();
System.out.println(map.toString());
}
}
my input is:
“u1” “u10”
“u2” “u41”
“u3” “u10”
“u4” “u81”
“u5” “u10”
“u6” “u10”
“u7” “u31”
“u8” “u11”
Output i got :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at excer4.main(excer4.java:15)
can any one help me to find a solution..