basically the same code that i used to copy contents of one file into another using FileInput and Output Streams only. That worked fine. But here i have just expanded to include another layer ,the DataInput and DataOutput Streams for chaining as they say. But only the first 4 integers are getting copied into the destination file, repeatedly. is this the behaviour of DataInputStream methods ? The api says so.... Returns: the next four bytes of this input stream, interpreted as an int. if this is ok then does this mean that they cannot be used to read files. Or if my code is not ok then let me know. (try and catch have not been included in the code here, but the code works fine)
You keep writing the int ii to the output stream, then you read an int from the input stream.....my question to you is, where are you storing the new value you read from the input stream? Rob
Rob
SCJP 1.4
mark stone
Ranch Hand
Joined: Dec 18, 2001
Posts: 417
posted
0
the int ii is reading the new value. and this value is written. next again value is read and is written. i used the same code ok with FileInputStream only. (no chains) here is the code FileOutputStream ff = new FileOutputStream ("c:\\test\\2copy.txt",true); FileInputStream fi = new FileInputStream ("c:\\test\\2.txt"); int ii=0;ii=fi.read(); while(ii != -1) {ff.write(ii);ii=fi.read(); this one is just fine and works great. if i am missing something please let me know
Originally posted by Rob Ross:
You keep writing the int ii to the output stream, then you read an int from the input stream.....my question to you is, where are you storing the new value you read from the input stream? Rob
Rob Ross
Bartender
Joined: Jan 07, 2002
Posts: 2205
posted
0
Originally posted by mark stone: the int ii is reading the new value. and this value is written. next again value is read and is written.
Not in the sample code you provided in your first post. Btw, to increase clarity I would suggest you make better use of white space. Try placing each statement on its own line. Rob
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.