@Override public Object getValue() { if (m_fromTextRadioButton.isSelected()) { return m_textField.getText().getBytes(); } else { File f = new File(m_fileField.getText()); if (!f.exists() || f.isDirectory()) { System.out.println("returning null..file doesnt exist"); return null; } try { ByteArrayOutputStream out = new ByteArrayOutputStream(); FileInputStream in = new FileInputStream(f); StreamUtility.pipeStream(in, out, 4096); return out.toByteArray(); } catch (IOException ioe) { System.out.println("ioexecption getting filestream: " + ioe.getMessage()); return null; } } }
public void getDatastreamDissemination( String pid, String dsId, String asOfDateTime, OutputStream out) throws IOException { InputStream in = getDatastreamDissemination(pid, dsId, asOfDateTime); StreamUtility.pipeStream(in, out, 4096); }
/** * Get data via HTTP and write it to an OutputStream, following redirects, and supplying * credentials if the host is the Fedora server. */ public void get(String url, OutputStream out) throws IOException { InputStream in = get(url); StreamUtility.pipeStream(in, out, 4096); }