I'm trying to load data from file into JTable. So, using Java 8 streams it is very easy to load file into array of strings:
BufferedReader br = new BufferedReader(new FileReader(f));
Object[] data = br.lines().map((s)->{
String[] res = {s,"1"}; // Here's some conversion of line into String[] - elements of one row
return res;
}).toArray();
TableModel m = new DefaultTableModel( (String[][])data, cols);
But the last line results in error: Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [[Ljava.lang.Object. How can I cast data to String[][]?