Results 1 to 5 of 5
- 03-04-2009, 10:23 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
Whats the difference between these two?
****1st case:
InputStream in;
DataInputStream stin;
HttpConnection hcon = (HttpConnection)Connector.open("http://example.com");
in = hcon.openInputStream();
stin = new DataInputStream(in);
//read data from stin
*****2nd case:
InputStream in;
DataInputStream stin;
HttpConnection hcon = (HttpConnection)Connector.open("http://example.com");
in = hcon.openInputStream();
//read data from in
well, im new to these terms.
- 03-04-2009, 10:29 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Only the difference is the following line of code.
So did you read about DataInputStream on Java doc?Java Code:stin = new DataInputStream(in);
- 03-04-2009, 10:57 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 40
- Rep Power
- 0
I meant whats the difference between execution of the two codes. Whats the purpose of opening a datainputstream on an inputstream? What advattage or disadvantage does it provide?
I read about datainputstream in the doc but understood nothing except the number of functions it provides
- 03-04-2009, 12:17 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Read the API docs for DataInputStream and InputStream and maybe you'll find out.
- 03-06-2009, 05:13 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yep, that's what I told too my friend. But seems to me, he's not clearly read the API. Or else, he cannot understand what Java doc says.
Simple extraction from the API.
public abstract class InputStream
extends Object
This abstract class is the superclass of all classes representing an input stream of bytespublic class DataInputStream
extends FilterInputStream
implements DataInput
A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream
Similar Threads
-
Whats wrong with my maths???
By soc86 in forum New To JavaReplies: 4Last Post: 11-03-2008, 05:52 PM -
whats my next step
By thirumurugan.sethu in forum New To JavaReplies: 4Last Post: 10-02-2008, 09:03 PM -
Cannot understand whats wrong
By Lehane_9 in forum New To JavaReplies: 1Last Post: 03-06-2008, 07:57 PM -
Whats wrong with my code???
By Soda in forum New To JavaReplies: 2Last Post: 12-06-2007, 12:54 PM -
whats the difference between Java core,J2EE......
By prince24 in forum New To JavaReplies: 2Last Post: 07-11-2007, 06:54 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks