• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I/O - Sun objective

 
Deepa sivasankar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this in the sun objective. Can someone explain to me ?. I appreciate your help.
"Destinguish between conditions under which platform default encoding conversion should be used and conditions under which a specific conversion should be used. "
Thanks
Deepa
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepa,
Readers and Writers accommodate different (Unicode) encoding schemes. Naturally they have constructors which take an encoding scheme as the argument and use it for reading/writing. If no encoding is explicitly specified, the default scheme is used.
For the SCJP, you are required to know, how to make use of such constructors. ie., if an encoding scheme is given to you, how would you construct the reader/writer object. You should also understand what a default scheme means, and how to construct reader/writer objects to make use of default schemes.
IMO, this is one of the easiest SCJP objectives and with little effort you can get the answers right. More about this in Java API Documentation.
Hope this helps,
Ajith
 
Jakob Bosshard
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepa
On top of what Ajith said, I would like to add the following links which explain internationalization. The first link gives a list of all encodings you can use for your I/O. The second is
just the top level link that explains the entire concept.
http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html
http://java.sun.com/products/jdk/1.2/docs/guide/internat/
Good luck
Jakob
 
Deepa sivasankar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ajith.
i have one more objective .
"Describe the permanent effects on the file system of constructing and using FileInputStream, FileOutputStream, and RandomAccessFile objects"
Can anyone explain or point me to the right place??
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's easy.
Permanent effect means some operation that has a durable effect on your local file system, even after the scope of the program. Something like a file being created/renamed/modified/deleted etc.
You will have to know which I/O classes has a permanent effect on the local file system. Creation usually happens when you create an output stream( and RandomAccessFile with a certain mode ), and if the file doesn't exist, then a new file will be created. I am intentionally being as brief as possible so that you can do some investigation yourself
Note that apart from streams, even the File object belongs to this category. Though File object only represents an abstract path, it provides pretty powerful methods to rename, delete the underlying file. You may have to read the question carefully if File is one of the options given to you.
Good luck and hope you will be able to find some more information on Java DOC API.
Ajith
 
Deepa sivasankar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks jakob.
 
Jakob Bosshard
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The fact is that the class file in java.io.File does not have any impact on the underlying file system. It is just a logical concept of a file. But as soon as you start to operate with streams such as FileInputStream or RandomAccessFile you really operate on the physical file. You should be aware that writing can overwrite the entire file etc. Just experiment with the methods of those streams, e.g.:
try {
File file = new File("C:/","NewFile.txt");
FileOutputStream fileOutput = new FileOutputStream(file);
fileOutput.close();
} catch(IOException e) {}
This code will create an empty file.
Have fun
Jakob
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jakob,
I will take your statement about File a pinch of salt.
You are right, File object will not create a file. However, it does a lot of other things which might leave a permanent effect on the local file system. For example, it can create directories,
it can rename files, it can even delete files. Take a look at these methods delete(),deleteOnExit(),renameTo()
This is one of the reasons why you need to be careful while taking the exam. Read the question twice especially if File is one of the answers given. On the issues mentioned above, it certainly can cause permanent effect on the file system.
Ajith
 
Eric Barnhill
Rancher
Posts: 233
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not to mention File.createNewFile() .
Eric B.
 
Jakob Bosshard
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajith and Eric
Thanks for your reply. I will carefully recheck the java.io.File and write some sample code to illustrate the permanent effects.
Thanks for telling me.
SEEYA
Jakob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic