static byte[] readStream(InputStream input) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); int read; byte[] buffer = new byte[256]; while ((read = input.read(buffer, 0, 256)) != -1) { bytes.write(buffer, 0, read); } return bytes.toByteArray(); }
public Transferable createTransferable(Drawing drawing, java.util.List<Figure> figures, double scaleFactor) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); write(buf, figures); return new InputStreamTransferable(new DataFlavor("text/html", "HTML Image Map"), buf.toByteArray()); }