本文整理汇总了Java中org.databene.commons.IOUtil.getContentOfURI方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtil.getContentOfURI方法的具体用法?Java IOUtil.getContentOfURI怎么用?Java IOUtil.getContentOfURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.databene.commons.IOUtil
的用法示例。
在下文中一共展示了IOUtil.getContentOfURI方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDocument
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public Document createDocument(String templateUri, String templateEncoding, Map<String, Object> variables) {
try {
// prepare generator
FreeMarkerScriptFactory factory = new FreeMarkerScriptFactory(Locale.ENGLISH);
String templateText = IOUtil.getContentOfURI(templateUri, templateEncoding);
Script script = factory.parseText(templateText);
Context context = new DefaultContext(variables);
// apply template
String xmlText = String.valueOf(script.evaluate(context));
// return result
return XMLUtil.parseString(xmlText);
}
catch (IOException e) {
throw new TechnicalException("Error creating XML document", e);
}
}
示例2: getText
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public String getText() {
try {
return IOUtil.getContentOfURI(fileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例3: testWriteTextFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void testWriteTextFile() throws Exception {
File file = new File("out.txt", service);
file.writeTextContent(new StringData("Demo"));
String content = IOUtil.getContentOfURI(ROOT + "/out.txt");
assertEquals("Demo", content);
}
示例4: testWriteTextFile_emptyFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void testWriteTextFile_emptyFile() throws Exception {
File file = new File("empty.txt", service);
file.writeTextContent(new StringData(""));
String content = IOUtil.getContentOfURI(ROOT + "/empty.txt");
assertEquals(0, content.length());
}
示例5: generate
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public String generate() {
assertInitialized();
try {
String absolutePath = generateFromSource().unwrap().getAbsolutePath();
return IOUtil.getContentOfURI(absolutePath);
} catch (IOException e) {
throw new IllegalGeneratorStateException(e);
}
}
示例6: resolveVariables
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
public File resolveVariables(File file) {
try {
String content = IOUtil.getContentOfURI(file.getAbsolutePath());
content = resolveVariables(content);
file.delete();
IOUtil.writeTextFile(file.getAbsolutePath(), content, getXMLEncoding());
return file;
} catch (IOException e) {
throw new I18NError("ErrorCreatingFile", e, file);
} finally {
advanceMonitor();
}
}
示例7: test
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
String uri = "target" + File.separator + getClass().getSimpleName() + ".txt";
TextFileExporter exporter = new TextFileExporter(uri);
exporter.startProductConsumption("test");
exporter.close();
assertEquals(uri, exporter.getUri());
String content = IOUtil.getContentOfURI(uri);
assertEquals("test" + SystemInfo.getLineSeparator(), content);
}
示例8: testHeadless
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void testHeadless() throws IOException {
context.setContextUri("/org/databene/benerator/engine/csv");
parseAndExecuteFile("/org/databene/benerator/engine/csv/headless_csv.ben.xml");
String generatedContent = IOUtil.getContentOfURI("target/headless-out.csv");
String expectedContent =
"ALICE,231,A\r\n" +
"BOB,341,B";
assertEquals(expectedContent, generatedContent);
}
示例9: testWriteTextFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void testWriteTextFile() throws Exception {
service.perform().writeTextFile("out.txt", "Demo", true);
String content = IOUtil.getContentOfURI(ROOT + "/out.txt");
assertEquals("Demo", content);
}
示例10: testWriteTextFile_emptyFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Test
public void testWriteTextFile_emptyFile() throws Exception {
service.perform().writeTextFile("empty.txt", "", true);
String content = IOUtil.getContentOfURI(ROOT + "/empty.txt");
assertEquals(0, content.length());
}
示例11: readFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public Script readFile(String uri) throws ParseException, IOException {
String text = IOUtil.getContentOfURI(uri);
return parseText(text);
}
示例12: parseAndExecuteFile
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
protected BeneratorContext parseAndExecuteFile(String filename) throws IOException {
String xml = IOUtil.getContentOfURI(filename);
return parseAndExecute(xml);
}
示例13: getContent
import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private String getContent(File file) throws IOException {
return IOUtil.getContentOfURI(file.getAbsolutePath());
}