Reading in text and casting it

From: neosenate (neosenate_at_netscape.net)
Date: 08/09/04


Date: 9 Aug 2004 07:30:57 -0700

Hi all,

I have to write a program that will take in a txt file containing a
number of floats, parse into individual numbers and then cast the
floats into binary, before writing all the binary numbers to another
file.

At the moment i've got

StreamTokenizer in = new StreamTokenizer(new
FileReader(filename.txt));

to read in the file and to convert the floats i'm going to use,

Integer.toBinaryString(Float.floatToRawIntBits(yourFloat));

The problem i'm coming across is that i'm trying to use a tokenizer to
break up the text, but when i try and cast it, i get an error saying
that i cannot cast a non-static variable.

some of the input data in the file looks like this... "13.5 8.2
8.8 3.4".

Any help would be greatly appreciated,

Cheers



Relevant Pages

  • Re: Looking for a general porpouse RCT
    ... you can cast the floats ... the ints, then cast back. ... precision floats the rounding errors for a round trip conversion are ...
    (comp.compression)
  • Re: Reading in text and casting it
    ... > floats into binary, before writing all the binary numbers to another ... > break up the text, but when i try and cast it, i get an error saying ... Sounds like you're not using your tokenizer right, ...
    (comp.lang.java.programmer)
  • Re: Looking for a general porpouse RCT
    ... you can cast the floats ... the ints, then cast back. ... precision floats the rounding errors for a round trip conversion are ...
    (comp.compression)
  • Re: Looking for a general porpouse RCT
    ... you can cast the floats ... to ints (which is approximately a logarithmic map), ... the ints, then cast back. ...
    (comp.compression)
  • Q/Confused
    ... I am trying to parse a data entry in a procedure. ... misc.cpp: In function `void chr_pad ... *)' lacks a cast ...
    (comp.lang.cpp)