本文整理了Java中org.apache.stanbol.enhancer.servicesapi.Blob.getStream()
方法的一些代码示例,展示了Blob.getStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.getStream()
方法的具体详情如下:
包路径:org.apache.stanbol.enhancer.servicesapi.Blob
类名称:Blob
方法名:getStream
[英]Getter for the data of this blob in form of an InputStream. Multiple calls need to return multiple instances of InputStreams
[中]以InputStream形式获取此blob的数据的Getter。多个调用需要返回InputStreams的多个实例
代码示例来源:origin: apache/stanbol
@Override
public final InputStream getStream() {
return getBlob().getStream();
}
@Override
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.servicesapi
@Override
public InputStream getStream() {
return getLazy().getStream();
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.servicesapi
@Override
public final InputStream getStream() {
return getBlob().getStream();
}
@Override
代码示例来源:origin: apache/stanbol
public static IRI makeDefaultUrn(Blob blob) {
return makeDefaultUri(DEFAULT_CONTENT_ITEM_PREFIX, blob.getStream());
}
public static IRI makeDefaultUrn(InputStream in) {
代码示例来源:origin: apache/stanbol
public static IRI makeDefaultUri(String baseUri, Blob blob) {
return makeDefaultUri(baseUri, blob.getStream());
}
public static IRI makeDefaultUri(String baseUri, byte[] data) {
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.servicesapi
public static IRI makeDefaultUrn(Blob blob) {
return makeDefaultUri(DEFAULT_CONTENT_ITEM_PREFIX, blob.getStream());
}
public static IRI makeDefaultUrn(InputStream in) {
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.servicesapi
public static IRI makeDefaultUri(String baseUri, Blob blob) {
return makeDefaultUri(baseUri, blob.getStream());
}
public static IRI makeDefaultUri(String baseUri, byte[] data) {
代码示例来源:origin: apache/stanbol
@Override
public InputStream getStream() {
return getLazy().getStream();
}
代码示例来源:origin: apache/stanbol
/**
* Getter for the Text of an {@link Blob}. This method respects the
* "charset" if present in the {@link Blob#getParameter() parameter} of the
* Blob.
* @param blob the {@link Blob}. MUST NOT be <code>null</code>.
* @return the text
* @throws IOException on any exception while reading from the
* {@link InputStream} provided by the Blob.
* @throws IllegalArgumentException if the parsed Blob is <code>null</code>
*/
public static String getText(Blob blob) throws IOException {
if(blob == null){
throw new IllegalArgumentException("The parsed Blob MUST NOT be NULL!");
}
String charset = blob.getParameter().get("charset");
return IOUtils.toString(blob.getStream(), charset != null ? charset : UTF8);
}
/**
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.servicesapi
/**
* Getter for the Text of an {@link Blob}. This method respects the
* "charset" if present in the {@link Blob#getParameter() parameter} of the
* Blob.
* @param blob the {@link Blob}. MUST NOT be <code>null</code>.
* @return the text
* @throws IOException on any exception while reading from the
* {@link InputStream} provided by the Blob.
* @throws IllegalArgumentException if the parsed Blob is <code>null</code>
*/
public static String getText(Blob blob) throws IOException {
if(blob == null){
throw new IllegalArgumentException("The parsed Blob MUST NOT be NULL!");
}
String charset = blob.getParameter().get("charset");
return IOUtils.toString(blob.getStream(), charset != null ? charset : UTF8);
}
/**
代码示例来源:origin: apache/stanbol
if(charset != null){
result = java.util.Collections.singleton(
backend.createLiteral(IOUtils.toString(blob.getStream(), charset)));
} else { //binary content
byte[] data = IOUtils.toByteArray(blob.getStream());
result = java.util.Collections.singleton(
(RDFTerm)lf.createTypedLiteral(data));
代码示例来源:origin: apache/stanbol
/**
* Tests correct handling of UTF-8 as default charset
* @throws IOException
*/
@Test
public void testString() throws IOException{
String test = "Exámplê";
//first via a StringSource
ContentSource cs = new StringSource(test);
Blob blob = createBlob(cs);
Assert.assertEquals("text/plain", blob.getMimeType());
Assert.assertTrue(blob.getParameter().containsKey("charset"));
Assert.assertEquals(UTF8.name(), blob.getParameter().get("charset"));
String value = new String(IOUtils.toByteArray(blob.getStream()),UTF8);
Assert.assertEquals(test, value);
}
/**
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.test
/**
* Tests correct handling of UTF-8 as default charset
* @throws IOException
*/
@Test
public void testString() throws IOException{
String test = "Exámplê";
//first via a StringSource
ContentSource cs = new StringSource(test);
Blob blob = createBlob(cs);
Assert.assertEquals("text/plain", blob.getMimeType());
Assert.assertTrue(blob.getParameter().containsKey("charset"));
Assert.assertEquals(UTF8.name(), blob.getParameter().get("charset"));
String value = new String(IOUtils.toByteArray(blob.getStream()),UTF8);
Assert.assertEquals(test, value);
}
/**
代码示例来源:origin: apache/stanbol
@Override
public void computeEnhancements(ContentItem ci) throws EngineException {
InputStream in = ci.getBlob().getStream();
XMPPacketScanner scanner = new XMPPacketScanner();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
scanner.parse(in, baos);
} catch (IOException e) {
throw new EngineException(e);
}
byte[] bytes = baos.toByteArray();
if (bytes.length > 0) {
Graph model = new IndexedGraph();
parser.parse(model, new ByteArrayInputStream(bytes), "application/rdf+xml");
GraphNode gn = new GraphNode(
new IRI("http://relative-uri.fake/"), model);
gn.replaceWith(ci.getUri());
ci.getLock().writeLock().lock();
try {
LOG.info("Model: {}",model);
ci.getMetadata().addAll(model);
} finally {
ci.getLock().writeLock().unlock();
}
}
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.jersey
contentPart.getValue().getStream(),readerCharset);
Writer writer = new OutputStreamWriter(entityStream, writerCharset);
IOUtils.copy(reader, writer);
mediaType.toString()+"; charset="+blobCharset);
InputStream in = contentPart.getValue().getStream();
IOUtils.copy(in, entityStream);
IOUtils.closeQuietly(in);
new InputStreamBody(blob.getStream(),ct));
代码示例来源:origin: apache/stanbol
cs.getBlob().getStream(),
charsetParam);
assertEquals(TEST_CONTENT, content);
代码示例来源:origin: apache/stanbol
blob.getStream(), blob.getContentLength(),
ContentType.create(blob.getMimeType(),
blob.getParameter().get("charset"))));
代码示例来源:origin: apache/stanbol
contentPart.getValue().getStream(),readerCharset);
Writer writer = new OutputStreamWriter(entityStream, writerCharset);
IOUtils.copy(reader, writer);
mediaType.toString()+"; charset="+blobCharset);
InputStream in = contentPart.getValue().getStream();
IOUtils.copy(in, entityStream);
IOUtils.closeQuietly(in);
new InputStreamBody(blob.getStream(),ct));
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.enhancer.test
cs.getBlob().getStream(),
charsetParam);
assertEquals(TEST_CONTENT, content);
代码示例来源:origin: apache/stanbol
request.addHeader(HttpHeaders.CONTENT_LANGUAGE, language);
request.setEntity(new InputStreamEntity(
blob.getStream(), blob.getContentLength(),
ContentType.create(blob.getMimeType(),
blob.getParameter().get("charset"))));
内容来源于网络,如有侵权,请联系作者删除!