Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2005

Tip: Looking for answers? Try searching our database.

how to read 16 - bit values?

Thread view: 
Rajesh.Rapaka - 28 Apr 2005 14:51 GMT
HI all,

I guess I am lost with all the fundamentals and all logical thinking.
plz help me.

I am using java. and I have an 16-bit image file. but this image file
contains of integer values ( in 16-bit). now using java how can i read
the 16-bit signed integer value ??

plz help !!
I know this should be a very very simple question. but failed to think
or find a gateway at this last moment.

kindly help
regards,
Rajesh RApaka.
foo - 28 Apr 2005 15:47 GMT
Do the following until you have read all bytes. File should have even
bytes.
Assumption is that while writing the high byte was written before the
low byte. If it's not true exchange b0 and b1 in line 3 and 5 of the
code.

short s = 0;
byte b0 = in.read(); byte b1 = in.read();
s = s | b0;
s << 8;
s = s | b1;
Greg Stark - 28 Apr 2005 23:21 GMT
Also, consider using the DataInputStream class instead. Or perhaps
ByteBuffer might be more appropriate?
Rajesh.Rapaka - 29 Apr 2005 07:17 GMT
this what I did !! But somehow it wrked very differently!! I guess i'll
check my codes again.

regards,
Rajesh Rapaka
bugbear - 29 Apr 2005 10:15 GMT
> HI all,
>
[quoted text clipped - 4 lines]
> contains of integer values ( in 16-bit). now using java how can i read
> the 16-bit signed integer value ??

Hmm Input. File. That might lead one to look in the java.io package.

java.io.DataInputStream

> A data input stream lets an application read primitive Java data
types > from an underlying input stream in a machine-independent way.

HTH.

  BugBear
Lee Ryman - 29 Apr 2005 13:16 GMT
> Hmm Input. File. That might lead one to look in the java.io package.
>
> java.io.DataInputStream

Your not, are you? You couldn't actually be suggesting someone reads the
API documentation? Don't you know that is utter madness? Do you not
realise the consequences of encouraging people to start reading API
docs? The constant flux of stupid newsgroup questions stemming from the
lack of common-sense is critical not only to the necessary daily
expression of sarcasm and wit by gurus (required to maintain the
inflation of their heads), but for the stability of our universe and the
space-time continuum. It is people like you with outrages implication
such as the necessity to RTFM before posting that will lead to the
downfall of society, the destruction of Earth, the Big-Crunch, and (god
give me the courage to mention it) actually _good_ software!
bugbear - 29 Apr 2005 16:42 GMT
> Your not, are you? You couldn't actually be suggesting someone reads the
> API documentation? Don't you know that is utter madness? Do you not
[quoted text clipped - 7 lines]
> downfall of society, the destruction of Earth, the Big-Crunch, and (god
> give me the courage to mention it) actually _good_ software!

<<chuckle>>

   BugBear


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.