I write to a .txt file a specific value that contains the time at which it was received. Here is the code (the code is ugly - these are only attempts to solve the necessary problem):
Pattern pattern = Pattern.compile("\\d+"); Matcher matcher = pattern.matcher(txtText); int start = 0; int []rez = {0,0,0,0}; while (matcher.find(start)) { String value = txtText.substring(matcher.start(), matcher.end()); int result = Integer.parseInt(value); rez[start] = result; start = matcher.end(); } if(rez[3]-100 < 0){ rez[0] = rez[0] * 10; if(rez[3]-10 < 0){ rez[0] = rez[0] * 10; } } System.out.println(rez[0]+" "+rez[3]); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); FileWriter writeFile = null; try { writeFile = new FileWriter(txtFile,true); writeFile.append(dateFormat.format(date)+"\t"); int foo = Integer.parseInt(rez[0]+""+rez[3]); writeFile.append(foo+"\n"); } catch (IOException e) { e.printStackTrace(); } finally { if(writeFile != null) { try { writeFile.close(); } catch (IOException e) { e.printStackTrace(); } } } The recorded file looks like this:
But during the subsequent import all the data goes in one piece, i.e. I can not get a specific row, or a specific cell (the intersection of a row and column). I understand that it is a matter of writing data to a file. How can I write data to a file so that it can be divided again?
UPD:
The thing is, I'm trying to import into Wolfram Mathematica . I tried to write not to .txt, but to .xls ( Wolfram Mathematica normally imports it) using Apache POI , but I could not write to the .xls file the dynamically received data: I use the write() method, but the append() method in the Apache POI library no. I'll try to deal with CSV - most likely, this is what I need (I already use TSV ).
UPD2:
The CSV option does not work: I use TSV , and the import still fails.
