Was pulling my hair out of this ! There are two data in text file. I trying to retrieve them out but I get below errors
########## Error with java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Object; ##########
Size 1
Code
try {
File file = new File(filePath + "ABC.txt");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
List list = new ArrayList();
try {
while ((st = br.readLine()) != null) {
String id = st.substring(92, 100);
try {
list.add(getDetail(id));
} catch (Exception e) {
e.printStackTrace();
}
for (Object[] o : (List<Object[]>) list) {
Details x = new Details();
x.setType(o[0].toString());
....
}
}
br.close();
} catch (Exception ex) {
logger.printError(Reader.class, "Error with " + ex);
}
logger.printInfo(Reader.class, "Size " + list.size());
} catch (IOException ex) {
ex.printStackTrace();
}
Query
public List getDetail(int id){
StringBuilder bf = new StringBuilder();
bf.append("SELECT ");
bf.append("'ABC', ");
....
return em.createQuery(bf.toString()) .getResultList();
}
Been stucked at here for more than 1 hour. Any help or advise would be much appreciated.