This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes data  type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "data  type" Watch "data  type" New topic
Author

data type

McWon
Greenhorn

Joined: Nov 16, 2000
Posts: 4
When I connect to a remote server using socket and read through the stream, I want to know the data type I am currently reading so that I can deal with them correspondingly. How can know the type of data I am reading? Could anyone please help?
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Please read and follow the Naming Policy. It can benefit you, read Book Promotions.
Unless you have first hand knowledge of the data types the server is sending and in what order, you can't. After all the word Help on the stream when read in as a byte array and converted to a string gives you 'Help' when read in as a 4 byte int gives you 1214606448.
Hope this helps

[This message has been edited by Carl Trusiak (edited January 18, 2001).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
McWon
Greenhorn

Joined: Nov 16, 2000
Posts: 4
Thanks Carl,
I am using readLine() method in BufferedReader class, is a whole .gif file read in a whole line?
I only want to deal with text/html files. How can I discriminate them from other file types, like .jpeg, .class and so? Can I make a decision after read a few characters?
How could I change my user name? reregister?
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Yes, reregister The software will allow you to change everything but your user name.
Your using the wrong Input method. BufferedReader reads in things as Unicode and this will corrupt the data in your file. You need to use BufferedInputStream.

Hope this helps
[This message has been edited by Carl Trusiak (edited January 18, 2001).]
[This message has been edited by Carl Trusiak (edited January 18, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: data type