A somewhat silly task.
code snippet
File someFile = new File("some_file.txt"); Charset someCharset = Charset.forName("windows-31j"); byte[] bytes1 = FileUtils.readFileToByteArray(someFile); String content1 = new String(bytes1, someCharset); byte[] bytes2 = content1.getBytes(someCharset); boolean isValid = Arrays.equals(bytes1, bytes2);