/** Returns the input stream of this media. * * <p>Note: the caller has to invoke {@link InputStream#close} * after using the input stream returned by {@link #getStreamData}. * * @exception IllegalStateException if the media is not binary * {@link #isBinary}. */ public InputStream getStreamData() { if (_isdata != null) return _isdata; if (_bindata != null) return new ByteArrayInputStream(_bindata); throw newIllegalStateException(); } /** Returns the reader of this media to retrieve the data.
/** Returns the reader of this media to retrieve the data. * * <p>Note: the caller has to invoke {@link Reader#close} * after using the input stream returned by {@link #getReaderData}. * * @exception IllegalStateException if the media is binary * {@link #isBinary}. */ public Reader getReaderData() { if (_rddata != null) return _rddata; if (_strdata != null) return new StringReader(_strdata); throw newIllegalStateException(); } private IllegalStateException newIllegalStateException() {
public String getStringData() { if (_strdata != null) return _strdata; Reader reader = _rddata == DYNAMIC_READER ? getReaderData() : _rddata; //ZK-938 if (reader != null) { try { String ct = Files.readAll(reader).toString(); reader.close(); return ct; } catch (java.io.IOException ex) { throw SystemException.Aide.wrap(ex); } } throw newIllegalStateException(); } /** Returns the input stream of this media.
public byte[] getByteData() { if (_bindata != null) return _bindata; InputStream is = _isdata == DYNAMIC_STREAM ? getStreamData() : _isdata ; //ZK-938 if (is != null) { try { byte[] bs = Files.readAll(is); is.close(); return bs; } catch (java.io.IOException ex) { throw SystemException.Aide.wrap(ex); } } throw newIllegalStateException(); } public String getStringData() {