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
|
@ -1,5 +1,8 @@
|
|||
1999-04-21 Tom Tromey <tromey@cygnus.com>
|
||||
|
||||
* java/lang/String.java: Don't throw
|
||||
UnsupportedEncodingException.
|
||||
|
||||
* java/lang/natString.cc (getBytes): Correctly size result
|
||||
buffer. From Bryce McKinlay <bryce@albatross.co.nz>.
|
||||
|
||||
|
|
|
@ -132,10 +132,28 @@ public final class String
|
|||
public native void getChars (int srcBegin, int srcEnd,
|
||||
char[] dst, int dstBegin);
|
||||
|
||||
public byte[] getBytes () throws UnsupportedEncodingException
|
||||
public byte[] getBytes ()
|
||||
{
|
||||
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)
|
||||
throws UnsupportedEncodingException;
|
||||
|
|
Loading…
Reference in New Issue