• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I/O - Sun objective

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks jakob.
 
Jakob Bosshard
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 241
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
not to mention File.createNewFile() .
Eric B.
 
Jakob Bosshard
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic