7143768: [macosx] Unexpected NullPointerException and java.io.IOException during DnD
authorkizune
Thu, 24 Jan 2013 16:09:48 +0400
changeset 15329 0607c1b65374
parent 15328 65d946035fa9
child 15330 1d23649a5422
7143768: [macosx] Unexpected NullPointerException and java.io.IOException during DnD Reviewed-by: alexp
jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Jan 24 15:55:04 2013 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Jan 24 16:09:48 2013 +0400
@@ -273,8 +273,31 @@
 
     @Override
     protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException {
-        // TODO Auto-generated method stub
-        return null;
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        for (int i = 0; i < fileList.size(); i++)
+        {
+            byte[] bytes = fileList.get(i).getBytes();
+            bos.write(bytes, 0, bytes.length);
+            bos.write(0);
+        }
+        return bos;
+    }
+
+    @Override
+    protected boolean isURIListFormat(long format) {
+        String nat = getNativeForFormat(format);
+        if (nat == null) {
+            return false;
+        }
+        try {
+            DataFlavor df = new DataFlavor(nat);
+            if (df.getPrimaryType().equals("text") && df.getSubType().equals("uri-list")) {
+                return true;
+            }
+        } catch (Exception e) {
+            // Not a MIME format.
+        }
+        return false;
     }
 }