类sun.awt.datatransfer.DataTransferer.ReencodingInputStream源码实例Demo

下面列出了怎么用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!");
            }
        }

    }
 
 类所在包
 类方法
 同包方法