...
| Code Block | ||
|---|---|---|
| ||
try {
FileInputStream fis = new FileInputStream("SomeFile");
DataInputStream dis = new DataInputStream(fis);
byte[] data = new byte[1024];
dis.readFully(data);
String encoding = "SomeEncoding"; // for example, "UTF-16LE"
String result = new String(data, encoding);
} catch (IOException x) {
// handle error
}
|
Exceptions
IDS13-EX0: An explicit character encoding may be omitted on the receiving side when the data was produced by a Java application that uses the same platform and default character encoding and the data is communicated over a secure communication channels (see MSC00-J. Use SSLSockets rather than Sockets for secure data exchange).
Risk Assessment
Failure to specify the character encoding while performing file or network I/O can result in corrupted data.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0a702db00735b27a-e35f2f5d-42a246de-90f3adcd-aed667963def46088d397bf7"><ac:plain-text-body><![CDATA[ | [[Encodings 2006 | AA. Bibliography#Encodings 06]] | ]]></ac:plain-text-body></ac:structured-macro> |
...