public static void main(String[] args) throws Exception { DataTransferer dataTransferer = new TestDataTransferer(); dataTransferer.registerTextFlavorProperties("UNICODE TEXT", "utf-16le", "\r\n", "2"); ByteTransferable transferable = new ByteTransferable(); ReencodingInputStream is = dataTransferer.new ReencodingInputStream(transferable.getByteInputStream(), TEXT_FORMAT, DataTransferer.getTextCharset(transferable.getDataFlavor()), transferable); byte[] bytes = transferable.getBytes(); byte[] result = new byte[bytes.length]; is.read(result); for (int i = 0; i < bytes.length; i++) { if (bytes[i] != result[i]) { throw new RuntimeException("Characters are not equal!"); } } }
public static void main(String[] args) throws Exception { DataTransferer dataTransferer = new TestDataTransferer(); dataTransferer.registerTextFlavorProperties("UNICODE TEXT", "utf-16le", "\r\n", "2"); ByteTransferable transferable = new ByteTransferable(); ReencodingInputStream is = dataTransferer.new ReencodingInputStream(transferable.getByteInputStream(), TEXT_FORMAT, DataFlavorUtil.getTextCharset(transferable.getDataFlavor()), transferable); byte[] bytes = transferable.getBytes(); byte[] result = new byte[bytes.length]; is.read(result); for (int i = 0; i < bytes.length; i++) { if (bytes[i] != result[i]) { throw new RuntimeException("Characters are not equal!"); } } }