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 String getData() { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { getDrawing().getOutputFormats().get(0).write(out, getDrawing()); return out.toString("UTF8"); } catch (IOException e) { SVGTextFigure tf = new SVGTextFigure(); tf.setText(e.getMessage()); tf.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100)); getDrawing().add(tf); e.printStackTrace(); return ""; } }
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()); }