當前位置: 首頁>>代碼示例>>Java>>正文


Java IOUtil.getFileContentAsString方法代碼示例

本文整理匯總了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) ;
  }
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:19,代碼來源:ScriptRunner.java

示例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");
  }
}
 
開發者ID:DemandCube,項目名稱:Scribengin,代碼行數:24,代碼來源:DataflowSubmitIntegrationTest.java

示例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 /");
  }
}
 
開發者ID:DemandCube,項目名稱:Scribengin,代碼行數:21,代碼來源:DataflowCommand.java

示例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();
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:8,代碼來源:MustacheTemplateUnitTest.java

示例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) ;
  }
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:11,代碼來源:ScriptRunner.java


注:本文中的com.neverwinterdp.util.IOUtil.getFileContentAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。