本文整理汇总了Java中org.apache.tika.io.IOUtils.toString方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtils.toString方法的具体用法?Java IOUtils.toString怎么用?Java IOUtils.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tika.io.IOUtils
的用法示例。
在下文中一共展示了IOUtils.toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReferenceFiles
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
public List<String> getReferenceFiles(Node rootNode,String path,String searchText) throws Exception{
List<String> referenceFiles=new ArrayList<String>();
List<String> files=getFiles(rootNode, path);
for(String nodePath:files){
InputStream inputStream=repositoryService.readFile(nodePath,null);
try {
String content = IOUtils.toString(inputStream);
inputStream.close();
boolean containPath=content.contains(path);
boolean containText=content.contains(searchText);
if(containPath && containText){
referenceFiles.add(nodePath);
}
} catch (IOException e) {
throw new RuleException(e);
}
}
return referenceFiles;
}
示例2: testPolicyCreateByPost
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Test
public void testPolicyCreateByPost() throws Exception {
final HttpPost objMethod = HttpPostObjMethod(POLICY_RESOURCE);
final StringEntity input = new StringEntity(MIME_KEY + " " + MIME + " " + STORE,
"UTF-8");
input.setContentType(APPLICATION_FORM_URLENCODED);
objMethod.setEntity(input);
final HttpResponse response = execute(objMethod);
final String body = IOUtils.toString(response.getEntity().getContent());
assertEquals(body, 201, response.getStatusLine().getStatusCode());
policyKeys.add(MIME_KEY);
final Header[] headers = response.getHeaders("Location");
assertNotNull(headers);
assertEquals(1, headers.length);
assertEquals(objMethod.getURI()
.toString()
.replace(POLICY_RESOURCE, MIME_KEY),
headers[0].getValue());
}
示例3: testGetStoragePolicy
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Test
public void testGetStoragePolicy() throws Exception {
// Test no policy
final HttpGet getMethod0 = HttpGetObjMethod(MIME_KEY);
final HttpResponse response0 = execute(getMethod0);
assertNotNull(response0);
assertEquals(IOUtils.toString(response0.getEntity().getContent()),
404,
response0.getStatusLine().getStatusCode());
// Add a policy
testPolicyCreateByPost();
// Test Get Storage Policy
final HttpGet getMethod1 = HttpGetObjMethod(MIME_KEY);
final HttpResponse response1 = execute(getMethod1);
assertNotNull(response1);
final String body = IOUtils.toString(response1.getEntity().getContent());
assertEquals(body, 200, response1.getStatusLine().getStatusCode());
assertEquals(MIME + ":" + STORE, body);
}
示例4: testGetStoragePolicies
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Test
public void testGetStoragePolicies() throws Exception {
// Add a policy
testPolicyCreateByPost();
// Test Get Storage Policy
final HttpGet getMethod1 = HttpGetObjMethod(POLICY_RESOURCE);
final HttpResponse response1 = execute(getMethod1);
assertNotNull(response1);
final String body = IOUtils.toString(response1.getEntity().getContent());
assertEquals(body, 200, response1.getStatusLine().getStatusCode());
final StoragePolicy policy = new MimeTypeStoragePolicy(MIME, STORE);
assertTrue("Didn't find our policy in policies!", body.contains(policy.toString()));
}
示例5: testGetContent
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Test
public void testGetContent() throws RepositoryException, IOException {
final String expected = "asdf";
getContentNodeMock(mockContent, expected);
when(mockDsNode.getNode(JCR_CONTENT)).thenReturn(mockContent);
final String actual = IOUtils.toString(testObj.getContent());
assertEquals(expected, actual);
verify(mockContent).getProperty(JCR_DATA);
}
示例6: testToInputStream
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Test
public void testToInputStream() throws IOException {
Observable<Buffer> buf = Observable.just(Buffer.buffer("text"));
try (InputStream ins = RxUtil.toInputStream(buf, Vertx.vertx())) {
String text = IOUtils.toString(ins);
assertEquals("text", text);
}
}
示例7: consumeOutput
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
@Override
public void consumeOutput(InputStream in) throws IOException {
if (in == null) {
return;
}
output = IOUtils.toString(in);
if (latch != null) {
latch.countDown();
}
}
示例8: script
import org.apache.tika.io.IOUtils; //导入方法依赖的package包/类
private String script() {
try {
InputStream in = this.getClass().getResourceAsStream(SCRIPT_NAME);
if(in == null) {
throw new RuntimeException(String.format("resource not found %s", SCRIPT_NAME));
}
return IOUtils.toString(in);
} catch(IOException e) {
throw new RuntimeException(e);
}
}