src/share/classes/sun/awt/datatransfer/DataTransferer.java

Print this page

        

@@ -1763,11 +1763,18 @@
             String unicode = DataTransferer.getTextCharset(DataFlavor.plainTextFlavor);
 
             Reader reader = new InputStreamReader(is, unicode);
 
             theObject = constructFlavoredObject(reader, flavor, Reader.class);
-
+            // Target data is a byte array
+        } else if (byteArrayClass.equals(flavor.getRepresentationClass())) {
+            if(isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
+                theObject = translateBytesToString(inputStreamToByteArray(str), format, localeTransferable)
+                        .getBytes(DataTransferer.getTextCharset(flavor));
+            } else {
+                theObject = inputStreamToByteArray(str);
+            }
             // Target data is an RMI object
         } else if (flavor.isRepresentationClassRemote()) {
 
             try (ObjectInputStream ois =
                      new ObjectInputStream(str))