★★Java質問・相談スレッド149★★
■ このスレッドは過去ログ倉庫に格納されています
0281デフォルトの名無しさん
2011/12/07(水) 13:06:20.46ファイル末尾の]の文字を削除すると正しくエンコードされます。
自動判定ではなく文字コードを指定しているのだから、
本来どのような内容でも正しくエンコードされるはずですが、
なぜでしょうか?
http://www.kent-web.com/pubc/book/test/uploader/uploader.cgi?mode=downld&no=4924
File f = new File("D:/encodeTest.txt");
byte[] src = TestUtility.read(f);
Charset c = Charset.forName("SJIS");
String encoded = new String(src, c);
System.out.println(encoded);
public class TestUtility {
public static byte[] read(File f) {
byte[] res = new byte[(int) f.length()];
try {
FileInputStream fb = new FileInputStream(f);
fb.read(res);
fb.close();
} catch (IOException e) {
e.printStackTrace();
}
return res;
}
}
■ このスレッドは過去ログ倉庫に格納されています