本文整理了Java中javax.activation.DataHandler.getInputStream()
方法的一些代码示例,展示了DataHandler.getInputStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataHandler.getInputStream()
方法的具体详情如下:
包路径:javax.activation.DataHandler
类名称:DataHandler
方法名:getInputStream
[英]Get the InputStream for this object.
For DataHandlers instantiated with a DataSource, the DataHandler calls the DataSource.getInputStream
method and returns the result to the caller.
For DataHandlers instantiated with an Object, the DataHandler first attempts to find a DataContentHandler for the Object. If the DataHandler can not find a DataContentHandler for this MIME type, it throws an UnsupportedDataTypeException. If it is successful, it creates a pipe and a thread. The thread uses the DataContentHandler's writeTo
method to write the stream data into one end of the pipe. The other end of the pipe is returned to the caller. Because a thread is created to copy the data, IOExceptions that may occur during the copy can not be propagated back to the caller. The result is an empty stream.
[中]获取此对象的InputStream。
对于使用数据源实例化的DataHandler,DataHandler调用DataSource.getInputStream
方法并将结果返回给调用者。
对于使用对象实例化的DataHandler,DataHandler首先尝试查找对象的DataContentHandler。如果DataHandler找不到此MIME类型的DataContentHandler,它将抛出UnsupportedDataTypeException。如果成功,它将创建一个管道和一个螺纹。线程使用DataContentHandler的writeTo
方法将流数据写入管道的一端。管道的另一端返回给调用者。因为创建线程是为了复制数据,所以复制过程中可能发生的IOException不能传播回调用方。结果是一个空流。
代码示例来源:origin: javax.activation/activation
/**
* Returns an <code>InputStream</code> representing this object.
* @return the <code>InputStream</code>
*/
public InputStream getInputStream() throws IOException {
return dataHandler.getInputStream();
}
代码示例来源:origin: com.sun.xml.bind/jaxb-impl
/**
* Gets the data as an {@link InputStream}.
*/
public InputStream getInputStream() throws IOException {
if (dataHandler != null) {
return dataHandler.getInputStream();
} else {
return new ByteArrayInputStream(data, 0, dataLen);
}
}
代码示例来源:origin: javax.activation/activation
public void setCommandContext(String verb, DataHandler dh) throws IOException {
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: javax.activation/activation
/**
* Set the DataHandler for this CommandObject
* @param DataHandler the DataHandler
*/
public void setCommandContext(String verb, DataHandler dh) throws IOException{
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: javax.activation/activation
public void setCommandContext(String verb, DataHandler dh) throws IOException {
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: spring-projects/spring-framework
@Override
public byte[] getAttachmentAsByteArray(String cid) {
try {
DataHandler dataHandler = getAttachmentAsDataHandler(cid);
return FileCopyUtils.copyToByteArray(dataHandler.getInputStream());
}
catch (IOException ex) {
throw new UnmarshallingFailureException("Couldn't read attachment", ex);
}
}
代码示例来源:origin: cloudfoundry/uaa
public String getContentString() throws MessagingException, IOException {
return StreamUtils.copyToString(mimeMessage.getDataHandler().getInputStream(), Charset.forName("UTF-8"));
}
代码示例来源:origin: javax.activation/activation
} else if (new_bean instanceof Externalizable) {
if (dh != null) {
InputStream is = dh.getInputStream();
if (is != null) {
((Externalizable)new_bean).readExternal(
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Returns an <code>InputStream</code> representing this object.
* @return the <code>InputStream</code>
*/
public InputStream getInputStream() throws IOException {
return dataHandler.getInputStream();
}
代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime
/**
* Gets the data as an {@link InputStream}.
*/
public InputStream getInputStream() throws IOException {
if (dataHandler != null) {
return dataHandler.getInputStream();
} else {
return new ByteArrayInputStream(data, 0, dataLen);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
public void setCommandContext(String verb, DataHandler dh) throws IOException {
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Set the DataHandler for this CommandObject
* @param DataHandler the DataHandler
*/
public void setCommandContext(String verb, DataHandler dh) throws IOException{
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: camunda/camunda-bpm-platform
public void setCommandContext(String verb, DataHandler dh) throws IOException {
_dh = dh;
this.setInputStream( _dh.getInputStream() );
}
//--------------------------------------------------------------------
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Return a decoded input stream for this body part's "content". <p>
*
* This implementation obtains the input stream from the DataHandler.
* That is, it invokes getDataHandler().getInputStream();
*
* @return an InputStream
* @exception IOException this is typically thrown by the
* DataHandler. Refer to the documentation for
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Return a decoded input stream for this Message's "content". <p>
*
* This implementation obtains the input stream from the DataHandler,
* that is, it invokes <code>getDataHandler().getInputStream()</code>.
*
* @return an InputStream
* @exception IOException this is typically thrown by the
* DataHandler. Refer to the documentation for
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Return a decoded input stream for this Message's "content". <p>
*
* This implementation obtains the input stream from the DataHandler,
* that is, it invokes <code>getDataHandler().getInputStream()</code>.
*
* @return an InputStream
* @exception IOException this is typically thrown by the
* DataHandler. Refer to the documentation for
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
@Override
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Return a decoded input stream for this body part's "content". <p>
*
* This implementation obtains the input stream from the DataHandler.
* That is, it invokes getDataHandler().getInputStream();
*
* @return an InputStream
* @exception IOException this is typically thrown by the
* DataHandler. Refer to the documentation for
* javax.activation.DataHandler for more details.
* @exception MessagingException for other failures
*
* @see #getContentStream
* @see javax.activation.DataHandler#getInputStream
*/
@Override
public InputStream getInputStream()
throws IOException, MessagingException {
return getDataHandler().getInputStream();
}
代码示例来源:origin: apache/nifi
final InputStream is = part.getDataHandler().getInputStream();
final String decodedText = StringUtils.newStringUtf8(Base64.decodeBase64(IOUtils.toString(is, "UTF-8")));
assertEquals("Message Body", decodedText);
final InputStream attachIs = attachPart.getDataHandler().getInputStream();
final String text = IOUtils.toString(attachIs, "UTF-8");
assertEquals("Some text", text);
代码示例来源:origin: opensourceBIM/BIMserver
@Override
public InputStream getDownloadData(String baseAddress, String token, long topicId) throws IOException {
try {
SDownloadResult downloadData = get(ServiceInterface.class).getDownloadData(topicId);
return downloadData.getFile().getInputStream();
} catch (ServerException e) {
LOGGER.error("", e);
} catch (UserException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
}
return null;
}
代码示例来源:origin: opensourceBIM/BIMserver
public void installPluginBundleFromFile(DataHandler file, Boolean installAllPluginsForAllUsers, Boolean installAllPluginsForNewUsers) throws UserException, ServerException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(file.getInputStream(), byteArrayOutputStream);
session.executeAndCommitAction(new InstallPluginBundleFromBytes(session, getInternalAccessMethod(), getBimServer(), byteArrayOutputStream.toByteArray(), installAllPluginsForAllUsers,
installAllPluginsForNewUsers));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!