MikeJava iNtelMac wrote:
Now i cud write to the file..
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
MikeJava iNtelMac wrote:If FileNotFoundException is thrown, then how come File overwrite check could be printed as true?
So i was wondering why only "Text" in place of TestText" whereas the file properly shows "TestText" when opened in notepad..
What i believe is when i am reading the file again via this code:
i understood why 101 & 116 are printed and then "Text" but cant figure out then why the characters 'T' & 's' were skipped..
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Miling Shah wrote:Well now as i you said.. i believe FileReader, BufferedReader and similar classes have synchronized methods that maintain a certain virtual or hidden lock on the file object being accessed.. isnt it?
If yes,do i need to call the .close() method on a FileReader object (being used first as compared to the BufferedReader object) and then read from the BufferedReader.. or is it Okay without .close() calls..
Why doesn't the File class have a .close() method..
so that whenever any other object, say a FileReader/Writer or FileInput/OutputStream object has finished its job.. the self-lock is activated.. something like a data protection feature.. ? Or any idea how i can implement it.?
Does the sequence of function call for object of classses operating on File objects such as FileReader, FileWriter, BufferedReader, BufferedWriter etc.. matter.. any rules as such to be followed?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
The new try-with-resources syntax will help you with that.
Miling Shah wrote:Closing a superclass object closes all subclass objects - like closing FileReader object stream also closes the BufferedReader object stream..
I assume that's what you meant by
The new try-with-resources syntax will help you with that.
Merry Christmas!
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
You've gotta fight it! Don't give in! Read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|