fix portability problem in Strings test

There was a test in Strings.java that assumed the default character
encoding was UTF-8, which is an invalid assumption on some platforms
(e.g. Windows).  This modifies the test to specify the encoding
explicitly.
This commit is contained in:
Joel Dice
2014-05-09 16:38:33 -06:00
parent 81958144a1
commit c35435e450
2 changed files with 14 additions and 6 deletions

View File

@ -24,6 +24,17 @@ public class PrintStream extends OutputStream {
this.autoFlush = autoFlush;
}
public PrintStream(OutputStream out, boolean autoFlush, String encoding)
throws UnsupportedEncodingException
{
this.out = out;
this.autoFlush = autoFlush;
if (! (encoding.equals("UTF-8") || encoding.equals("ISO-8859-1"))) {
throw new UnsupportedEncodingException(encoding);
}
}
public PrintStream(OutputStream out) {
this(out, false);
}