List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:gaffer.example.util.JavaSourceUtil.java
public static String getRawJava(final String className, final String modulePath) { try {// w w w.j av a 2 s . c o m String path = JAVA_SRC_PATH + className.replace(".", "/") + ".java"; if (!new File("").getAbsolutePath().endsWith(modulePath)) { path = modulePath + "/" + path; } final String javaCode = FileUtils.readFileToString(new File(path)); return javaCode.substring(javaCode.indexOf("public class ")); } catch (final IOException e) { throw new RuntimeException( "Unable find the java source code, this code is used to generate the Wiki and requires access to the Gaffer source code. Please run the code from within the Gaffer parent directory.", e); } }
From source file:de.tudarmstadt.ukp.dkpro.argumentation.annotations.Tools.java
public static String dumpCas(JCas jCas) { try {//ww w . j ava 2 s. co m File f = File.createTempFile("casdump", ".txt"); SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngineDescription(CasDumpWriter.class, CasDumpWriter.PARAM_OUTPUT_FILE, f)); StringBuilder result = new StringBuilder(FileUtils.readFileToString(f)); FileUtils.deleteQuietly(f); result.append("Id:").append(DocumentMetaData.get(jCas).getDocumentId()); return result.toString(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:File.TXT.ReadFile.java
/** * @param args the command line arguments *//*from w w w . j a v a 2 s .co m*/ public String read(String path, String nama_file) { String hasil = ""; File f = new File(path + nama_file); if (f.canRead()) { try { hasil = FileUtils.readFileToString(f); return hasil; } catch (IOException ex) { hasil = ex.getMessage(); Logger.getLogger(ReadFile.class.getName()).log(Level.SEVERE, null, ex); } } return hasil; }
From source file:com.bluexml.tools.miscellaneous.ConvertFileContentIntoJSString.java
protected static void writeFiles(File input, File output) { try {//from w ww. j a va 2 s .com String readFileToString = FileUtils.readFileToString(input); readFileToString = readFileToString.replaceAll("\"", "\\\\\""); readFileToString = readFileToString.replaceAll("\n", "\\\\n\\\\\\\n"); if (readFileToString.endsWith("\n")) { readFileToString = readFileToString.substring(0, readFileToString.length() - 2); } readFileToString = nativeToAscii("\"" + readFileToString + "\""); System.out.println(readFileToString); FileUtils.writeStringToFile(output, readFileToString, "UTF-8"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.thoughtworks.go.config.GuidService.java
public static boolean guidPresent() { try {//from w w w. ja v a2s . c o m String guid = FileUtils.readFileToString(AGENT_GUID_FILE); return (guid != null && guid.length() > 0); } catch (IOException ioe) { return false; } }
From source file:com.mirth.connect.server.tools.ScriptRunner.java
/** * This will run the script using the database connector that has been * defined/* w w w.j a va2 s .com*/ * * @param scriptFile */ public static void runScript(File scriptFile) { try { DatabaseUtil.executeScript(FileUtils.readFileToString(scriptFile), false); } catch (Exception e) { e.printStackTrace(); } }
From source file:cmg.org.monitor.ext.util.IOUtil.java
/** * Read resource./*from w ww. j a v a 2s. c o m*/ * * @param path the path * @return the string * @throws IOException Signals that an I/O exception has occurred. */ public static String readResource(String path) throws IOException { try { return FileUtils.readFileToString(FileUtils.toFile(IOUtil.class.getResource(path))); } catch (IOException e) { throw e; } }
From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java
private void initComponents() { try {//from w ww . j a v a2s . c om String licenseStr = FileUtils.readFileToString(new File(ConfigManager.GPL_LICENSE_FILE)); licenseText = new JTextArea(licenseStr); licenseText.setColumns(20); licenseText.setRows(15); licenseText.setBorder(BorderFactory.createLineBorder(UIAccessories.BORDER_GRAY)); licenseText.setBackground(UIAccessories.WHITE); licenseText.setEditable(false); JScrollPane scrollPane = new JScrollPane(licenseText); scrollPane.setBorder(null); scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.getViewport().setBorder(null); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); setLayout(new BorderLayout(20, 20)); add(createTransparentFillerPanel(), BorderLayout.NORTH); add(scrollPane, BorderLayout.CENTER); } catch (IOException e) { e.printStackTrace(); } this.setOpaque(false); }
From source file:com.ebay.logstorm.core.compiler.PipelineCompiler.java
public static Pipeline compileResource(String resource) throws IOException, PipelineException { URL resourceUrl = PipelineCompiler.class.getResource(resource); if (resourceUrl == null) { throw new IOException("Resource " + resource + " not found"); } else {/*from w ww . j a v a2 s . c om*/ return compileConfigString(FileUtils.readFileToString(new File(resourceUrl.getPath()))); } }
From source file:mrdshinse.md2html.util.FileUtil.java
/** * Get file content by String./*www .ja v a2 s . c o m*/ * * @param file file * @return file content */ public static String toString(File file) { try { return FileUtils.readFileToString(file); } catch (IOException ex) { LOG.error(ex); return ""; } }