I'm trying to create a .txt reader and inserting the read data to the cleansheets software we are editing in class but instead of putting the correct data it does nothing. I made some prints and this is what I obtain:
D:\Documentos\Desktop\ImportTest.txt
cacacaca ----- [[Ljava.lang.String;@73a175]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2, [Ljava.lang.String;@5f3215]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2, [Ljava.lang.String;@5f3215, [Ljava.lang.String;@5a421d]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2, [Ljava.lang.String;@5f3215, [Ljava.lang.String;@5a421d, [Ljava.lang.String;@1f528ea]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2, [Ljava.lang.String;@5f3215, [Ljava.lang.String;@5a421d, [Ljava.lang.String;@1f528ea, [Ljava.lang.String;@12aa4ba]
cacacaca ----- [[Ljava.lang.String;@73a175, [Ljava.lang.String;@364cf2, [Ljava.lang.String;@5f3215, [Ljava.lang.String;@5a421d, [Ljava.lang.String;@1f528ea, [Ljava.lang.String;@12aa4ba, [Ljava.lang.String;@e4e190]
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
cocococo ----- [[Ljava.lang.String;@a011bb
Done
This is the code I made so far:
try {
//Creates a file
JFileChooser chooser;
File ficheiro = null;
chooser = new JFileChooser();
//Creates a filter to 'TXT'
chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter());
FileFilter filterTXT = new FileNameExtensionFilter("TXT File", "txt");
chooser.setFileFilter(filterTXT);
//Opens the dialog window to choose the file to import.
int success = chooser.showOpenDialog(null);
if (success == JFileChooser.APPROVE_OPTION) {
ficheiro = chooser.getSelectedFile();
InputStream is = new FileInputStream(ficheiro);
Reader streamReader = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(streamReader);
System.out.println(ficheiro.toString());
// Reads content of rows
String line;
int columns = 0;
List<String[]> rows = new LinkedList<String[]>();
while ((line = reader.readLine()) != null) {
String[] row = line.split(";");
rows.add(row);
if (row.length > columns) {
columns = row.length;
}
System.out.println("cacacaca ----- " + rows);
}
System.out.println("\n");
// Builds content matrix
String[][] content = new String[rows.size()][columns];
int i = 0;
for (String[] row : rows) {
content[i++] = row;
System.out.println("cocococo ----- " + content);
}
reader.close();
Workbook workbook = new Workbook(content);
}
System.out.println("Done");
} catch (IOException ex) {
Logger.getLogger(ImporterAction.class.getName()).log(Level.SEVERE, null, ex);
}
If someone can help, I'd aprecciate! :)