Re: read doubles from file



Cri wrote:
Hi

I have a file that contains 3 lines like that:

X=[-1.0 -0.95315 0.783145 0.568942......]
Y=[-1.0 -1.0 0.783145 0.568942......]
Z=[-0.45315 0.233145 0.94234......]

I have to read it y store the data in 3 arrays. The file is created
using the BufferedWriter class, but to read it BufferedReader reads
lines so I can't use it because I had one String for each line, and I
don't know how to separate each double in String in components.

Also I have tried to use the DataInputStream class that has a readDouble
function but it doesn't work.

What can I do?

Thank you very much
You have used BufferedWriter. So they should be all strings.
Then, you have to use BuffereReader.readLine() for inputting
each line of string. Parse each line using regular expression.
Show us a detailed example of lines in your next post. I could
show an example parsing code. Add description for your
parsing requirement.

.



Relevant Pages

  • Re: HTTPS-Client bringt Fehler beim Wechsel von getIntputStream() auf getOutputStream
    ... Der HTML-Parser durchsucht die Seite und findet die SessionId und stellt sie in die Variable "action". ... Die Session in diesem Programm wird über Querystring gehalten; mit den Cookies bin ich auch nicht weiter gekommen. ... String line; ... BufferedWriter outx = new BufferedWriter(new ...
    (de.comp.lang.java)
  • Re: Java-Webstart/Exception - Nicht ausreichend Rechte?
    ... String message) { ... FileWriter fileWriter = new FileWriter ... BufferedWriter bufferedWriter = new BufferedWriter; ... Die IOException ruft dann die Funktion printToLogFile erneut auf :-) Wenn die Ausnahme auftritt, bevor das Verzeichnis angelegt wird, habe ich ein Problem. ...
    (de.comp.lang.java)
  • Reading Emails
    ... BufferedWriter out = new BufferedWriter( ... public String getMail ... (BufferedReader in, BufferedWriter out, int i) ... throws IOException { ...
    (comp.lang.java.gui)
  • Reading Emails
    ... BufferedWriter out = new BufferedWriter( ... public String getMail ... (BufferedReader in, BufferedWriter out, int i) ... throws IOException { ...
    (comp.lang.java.programmer)
  • Re: variable size record length file parsing
    ... You could use a class that exposes a Data property (String) ... and all the other UDT members as properties. ... That would help to move that parsing code out into a ...
    (microsoft.public.vb.general.discussion)