List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:com.sqatntu.testutil.TestUtil.java
public static String loadFile(String filePath) throws IOException { File file = new File(filePath); return FileUtils.readFileToString(file); }
From source file:mrdshinse.sql2xlsx.util.FileUtil.java
public static String toString(File file) { try {//from w ww . j a v a2s .com return FileUtils.readFileToString(file); } catch (IOException ex) { return null; } }
From source file:au.edu.unsw.cse.soc.federatedcloud.DataModelUtil.java
/** * Process an file and returns the CloudResourceDescription * * @param aFile input file to be processed (must be a JSON file) *///from www .ja va 2 s .c o m private static CloudResourceDescription processFile(File aFile) throws Exception { try { String fileContent = FileUtils.readFileToString(aFile); return readJSON(fileContent); } catch (Exception e) { throw new Exception("Error occured when processing:" + aFile.getAbsolutePath(), e); } }
From source file:cl.almejo.vsim.Main.java
public Main() throws IOException { File file = new File("circuit.json"); Circuit circuit = Circuit.fromJSon(FileUtils.readFileToString(file), file.getAbsolutePath()); if ("native".equalsIgnoreCase(System.getProperty("vsim.look"))) { setNativeLookAndFeel();//from w w w.j a v a 2 s . co m } else if ("Nimbus".equalsIgnoreCase(System.getProperty("vsim.look"))) { setNimbusLookAndFeel(); } new SimWindow(circuit); }
From source file:com.galenframework.ide.services.filebrowser.FileContent.java
public static FileContent fromFile(String path) { File file = new File(path); if (file.exists()) { if (!file.isDirectory()) { String content;/*from ww w .j a v a 2 s .c o m*/ try { content = FileUtils.readFileToString(file); } catch (IOException e) { throw new RuntimeException("Couldn't read file contents: " + path, e); } return new FileContent(file.getName(), file.getPath(), content); } else throw new RuntimeException("Path is a directory: " + path); } else throw new RuntimeException("File is not found: " + path); }
From source file:ezbake.crypto.RSAKeyCryptoTest.java
@BeforeClass public static void init() throws IOException { log.info("RSAKeyCrypto JUnit Test Initialization"); privateKey = FileUtils.readFileToString(new File(serverPrivatePath)); }
From source file:net.kubin.blocks.BlockJSONLoader.java
public static void parseJSON() throws Exception { String jsonFile = FileUtils.readFileToString(new File("res/blocks.json")); JSONObject jsonData = new JSONObject(jsonFile); /* Get NodeList of all the blocks */ JSONArray blocksList = jsonData.getJSONArray("blocks"); for (int i = 0; i < blocksList.length(); ++i) { JSONObject blockObject = blocksList.getJSONObject(i); BlockDef blockDef = parseBlockDef(blockObject); BlockManager.getInstance().addBlock(blockDef); }// ww w. ja v a 2s .co m BlockManager.getInstance().load(); }
From source file:com.sap.prd.mobile.ios.mios.XCodeTest.java
private static void filterPoms(File projectDirectory) throws IOException { Set<File> pomFiles = new HashSet<File>(); getPomFiles(projectDirectory, pomFiles); for (File pomFile : pomFiles) { String pom = FileUtils.readFileToString(pomFile); pom = pom.replaceAll("\\$\\{xcode.maven.plugin.version\\}", getMavenXcodePluginVersion()); FileUtils.writeStringToFile(pomFile, pom, "UTF-8"); }// w w w .jav a2 s .co m }
From source file:de.tudarmstadt.ukp.dkpro.tc.ml.modelpersist.ModelPersistUtil.java
public static TCMachineLearningAdapter initMachineLearningAdapter(File tcModelLocation) throws Exception { File modelMeta = new File(tcModelLocation, MODEL_META); String fileContent = FileUtils.readFileToString(modelMeta); Class<?> classObj = Class.forName(fileContent); return (TCMachineLearningAdapter) classObj.newInstance(); }
From source file:com.flipkart.poseidon.api.APILoaderTest.java
@BeforeClass public static void setUp() throws Exception { legoSet = mock(PoseidonLegoSet.class); configuration = mock(Configuration.class); File testApiFile = new File("src/test/resources/api/test.json"); File testApiSlashFile = new File("src/test/resources/api/testSlash.json"); String config1 = FileUtils.readFileToString(testApiFile); String config2 = FileUtils.readFileToString(testApiSlashFile); configs = String.format("[ %s, %s ]", config1, config2); }