cleaned up old hack to check that aCharset is supported

This commit is contained in:
Lars Kühne 2008-04-28 20:10:17 +00:00
parent 3b0a175562
commit fa3199e2bc
1 changed files with 3 additions and 7 deletions

View File

@ -21,6 +21,7 @@ package com.puppycrawl.tools.checkstyle.api;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.List;
/**
@ -63,13 +64,8 @@ public abstract class AbstractFileSetCheck
public void setCharset(String aCharset)
throws UnsupportedEncodingException
{
// TODO: This is a hack to check that aCharset is supported.
// TODO: Find a better way in Java 1.3
try {
new String(new byte[] {}, aCharset);
}
catch (final UnsupportedEncodingException es) {
final String message = "unsupported charset: " + es.getMessage();
if (!Charset.isSupported(aCharset)) {
final String message = "unsupported charset: '" + aCharset + "'";
throw new UnsupportedEncodingException(message);
}
mCharset = aCharset;