下面列出了怎么用sun.awt.datatransfer.DataTransferer.ReencodingInputStream的API类实例代码及写法,或者点击链接到github查看源代码。
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,
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,
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,
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,
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!");
}
}
}
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,
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,
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,
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,
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,
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,
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!");
}
}
}