本文整理匯總了Java中com.neverwinterdp.util.IOUtil.getFileContentAsString方法的典型用法代碼示例。如果您正苦於以下問題:Java IOUtil.getFileContentAsString方法的具體用法?Java IOUtil.getFileContentAsString怎麽用?Java IOUtil.getFileContentAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.neverwinterdp.util.IOUtil
的用法示例。
在下文中一共展示了IOUtil.getFileContentAsString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: require
import com.neverwinterdp.util.IOUtil; //導入方法依賴的package包/類
public void require(String scriptFile) {
if(loadedFiles.contains(scriptFile)) return ;
try {
String script = null ;
if(scriptFile.startsWith("classpath:") || scriptFile.startsWith("file:")) {
System.err.println("Script File: " + scriptFile) ;
script = IOUtil.getStreamContentAsString(IOUtil.loadRes(scriptFile), "UTF-8") ;
} else {
script = IOUtil.getFileContentAsString(libDir + "/" + scriptFile, "UTF-8") ;
}
loadedFiles.add(scriptFile) ;
engine.put(ScriptEngine.FILENAME, scriptFile);
engine.eval(script);
} catch(Exception ex) {
ex.printStackTrace() ;
throw new RuntimeException(ex) ;
}
}
示例2: testHdfsDataflow
import com.neverwinterdp.util.IOUtil; //導入方法依賴的package包/類
@Test
public void testHdfsDataflow() throws Exception {
ScribenginShell shell = new ScribenginShell(clusterBuilder.getVMClusterBuilder().getVMClient());
FileSystem fs = getFileSystem();
try {
HelloHDFSDataflowBuilder hdfDataflowBuilder =
new HelloHDFSDataflowBuilder(clusterBuilder.getScribenginClient(), fs, getDataDir());
hdfDataflowBuilder.createSource(15, 3, 5);
ScribenginClient scribenginClient = clusterBuilder.getScribenginClient();
String dataflowJson = IOUtil.getFileContentAsString("src/dataflows/hdfs/dataflow.json") ;
ScribenginWaitingEventListener eventListener =
scribenginClient.submit("build/release/dataflows/hdfs", dataflowJson);
eventListener.waitForEvents(60000);
} catch(Exception ex) {
ex.printStackTrace();
} finally {
Thread.sleep(3000);
shell.execute("vm info");
shell.execute("registry dump --path /");
HDFSUtil.dump(fs, getDataDir() + "/sink");
HDFSUtil.dump(fs, getDataDir() + "/invalid-sink");
}
}
示例3: execute
import com.neverwinterdp.util.IOUtil; //導入方法依賴的package包/類
@Override
public void execute(Shell shell, CommandInput cmdInput) throws Exception {
ScribenginShell scribenginShell = (ScribenginShell) shell;
ScribenginClient scribenginClient= scribenginShell.getScribenginClient();
try {
String dataflowJson = IOUtil.getFileContentAsString(descriptor) ;
System.out.println("Dataflow JSON:");
System.out.println(dataflowJson);
ScribenginWaitingEventListener eventListener = scribenginClient.submit(dataflowPath, dataflowJson);
System.out.println("Submited.................");
eventListener.waitForEvents(60000);
System.out.println("Finish wait for event..........");
} catch(Exception ex) {
ex.printStackTrace();
} finally {
Thread.sleep(3000);
shell.execute("vm info");
shell.execute("registry dump --path /");
}
}
示例4: testPOJO
import com.neverwinterdp.util.IOUtil; //導入方法依賴的package包/類
@Test
public void testPOJO() throws Exception {
String template = IOUtil.getFileContentAsString("src/test/resources/mustache/hello.mtpl") ;
MustacheFactory mf = new DefaultMustacheFactory();
Mustache mustache = mf.compile(new StringReader(template), "hello");
mustache.execute(new PrintWriter(System.out), new MustacheTemplateUnitTest()).flush();
}
示例5: runScript
import com.neverwinterdp.util.IOUtil; //導入方法依賴的package包/類
public void runScript(String scriptFile) {
try {
String script = IOUtil.getFileContentAsString(scriptFile, "UTF-8") ;
engine.put(ScriptEngine.FILENAME, scriptFile);
engine.eval(script);
} catch(Exception ex) {
ex.printStackTrace() ;
throw new RuntimeException(ex) ;
}
}