Go Back   Java Programming Forums > Java Standard Edition Programming Help > File I/O & Other I/O Streams


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25-06-2009, 08:36 PM
Junior Member
 

Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
username9000 is on a distinguished road
Default Reading IEEE float values from files.

FileInputSream, BufferedInputStream
FileReader, BufferedReader

These classes AFAIK only have read methods which return strings, char arrays or byte arrays, or single bytes. The problem is if I want to read 2 byte floats or 4 byte double precision IEEE floating point numbers, how do I read them and use them in java?? I really don't to read these byte by byte and have to do manual binary number manipulation and reading.

Thanks for reading! Thanks for helpful comments in advance!



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 25-06-2009, 09:22 PM
Freaky Chris's Avatar
Senile Half-Wit
 

Join Date: Mar 2009
Location: UK
Posts: 621
Thanks: 2
Thanked 64 Times in 60 Posts
Freaky Chris will become famous soon enoughFreaky Chris will become famous soon enoughFreaky Chris will become famous soon enough

I'm feeling Cheerful
Default Re: Reading IEEE float values from files.

Read them into a string then use

Java Code
double myDouble = Double.valueOf(theString);
Regards,
Chris
__________________
chris[at]javaprogrammingforums[dot]com

University of Wales, Bangor
Reply With Quote
  #3 (permalink)  
Old 30-06-2009, 05:20 PM
Junior Member
 

Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
username9000 is on a distinguished road
Default Re: Reading IEEE float values from files.

I tried this but it only seems to read the number as the ascii representation not the actual value, ie. it reads 0x3132 as 12 from the ascii character for 0x31 for 2 and the ascii character for 0x32 is 2, but what I need is the actual number (IEEE integer) as in 0x3132 is 12849.
Reply With Quote
  #4 (permalink)  
Old 30-06-2009, 05:56 PM
Junior Member
 

Join Date: Jun 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
username9000 is on a distinguished road
Default Re: Reading IEEE float values from files.

Nvm I found the answer, DataInputStream lets you read all data types including unsigned values. Except I still don't know how to handle big-endian little-endianess.

Last edited by username9000; 30-06-2009 at 07:12 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using 3rd Party JAR Files oss_2008 Java Theory & Questions 12 12-06-2009 03:27 PM
How to Populate all array values using the java.util.Arrays class JavaPF Java Code Snippets and Tutorials 0 07-04-2009 10:31 AM
How to check an input is an integer as oppose to a float Konnor File I/O & Other I/O Streams 3 02-02-2009 09:37 AM
code help 2 programs. MinMax Values & Converting Temps. awake77 What's Wrong With My Code? 6 20-12-2008 09:12 PM
Float to binary rosh72851 Java Theory & Questions 1 08-10-2008 03:45 AM


100 most searched terms
Search Cloud
2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java http://www.javaprogrammingforums.com/object-oriented-programming/3713-limiting-decimal-places-double.html java 2d arraylist java actionlistener java addactionlistener java double format java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programmers forum java programming forum java programming forums java programming help java project ideas java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextarea font color jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream two dimensional arraylist java writing ipod apps

All times are GMT. The time now is 11:31 PM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.