當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。