String.java: Don't throw UnsupportedEncodingException.
* java/lang/String.java: Don't throw UnsupportedEncodingException. From-SVN: r26577
This commit is contained in:
parent
b323effe6d
commit
9d9cf1661d
2 changed files with 23 additions and 2 deletions
|
@ -132,9 +132,27 @@ public final class String
|
|||
public native void getChars (int srcBegin, int srcEnd,
|
||||
char[] dst, int dstBegin);
|
||||
|
||||
public byte[] getBytes () throws UnsupportedEncodingException
|
||||
public byte[] getBytes ()
|
||||
{
|
||||
return getBytes (System.getProperty("file.encoding", "8859_1"));
|
||||
try
|
||||
{
|
||||
return getBytes (System.getProperty("file.encoding", "8859_1"));
|
||||
}
|
||||
catch (UnsupportedEncodingException x)
|
||||
{
|
||||
// This probably shouldn't happen, but could if file.encoding
|
||||
// is somehow changed to a value we don't understand.
|
||||
try
|
||||
{
|
||||
return getBytes ("8859_1");
|
||||
}
|
||||
catch (UnsupportedEncodingException x2)
|
||||
{
|
||||
// This really shouldn't happen, because the 8859_1
|
||||
// encoding should always be available.
|
||||
throw new InternalError ("couldn't find 8859_1 encoder");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public native byte[] getBytes (String enc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue