当前位置: 首页>>代码示例>>Java>>正文


Java IOUtil.getContentOfURI方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:18,代码来源:XmlContentImpl.java

示例2: getText

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
@Override
public String getText() {
   	try {
		return IOUtil.getContentOfURI(fileName);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
   }
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:9,代码来源:ANTLRNoCaseFileStream.java

示例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);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:8,代码来源:FileTest.java

示例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());
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:8,代码来源:FileTest.java

示例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);
       }
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:11,代码来源:TextFileContentGenerator.java

示例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();
}
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:14,代码来源:ProjectBuilder.java

示例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);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:11,代码来源:TextFileExporterTest.java

示例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);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:12,代码来源:CSVIntegrationTest.java

示例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);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:7,代码来源:LocalFileServiceTest.java

示例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());
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:7,代码来源:LocalFileServiceTest.java

示例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);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:6,代码来源:BeneratorScriptFactory.java

示例12: parseAndExecuteFile

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
protected BeneratorContext parseAndExecuteFile(String filename) throws IOException {
String xml = IOUtil.getContentOfURI(filename);
return parseAndExecute(xml);
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:5,代码来源:BeneratorIntegrationTest.java

示例13: getContent

import org.databene.commons.IOUtil; //导入方法依赖的package包/类
private String getContent(File file) throws IOException {
 return IOUtil.getContentOfURI(file.getAbsolutePath());
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:4,代码来源:CSVEntityExporterTest.java


注:本文中的org.databene.commons.IOUtil.getContentOfURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。