Question 33) Which of the following statements are true? 1) Java uses a system called UTF for I/O to support international character sets 2) The RandomAccessFile is the most suitable class for supporting international character sets 3) An instance of FileInputStream may not be chained to an instance of FileOutputStream 4) File I/O activities requires use of Exception handling Answer = 1,3,4 Answer 1 should be UTF-8 right? I don't know if there are different UTFs, but I didn't check it since it didn't say UTF-8.
Coll thanks for the link. So the answer should be UTF-8 right?
Joined: Jul 03, 2001
Not necessarily. For internationalization you can use charsetsfor converting between Java characters or strings and the especified charset. The following charsets must be supported:
US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 UTF-8 Eight-bit UCS Transformation Format UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark
You can pass them as parameters to the InputStreamReader and OutputStreamWriter constructors. Also you can pass a charset to the java.lang.String)" target="_blank" rel="nofollow">String.getBytes(String) method. Not passing any charset to these methods will let the JVM to use the platform default.