List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:com.netflix.spinnaker.clouddriver.artifacts.CredentialReader.java
public static String credentialsFromFile(String filename) { try {//from ww w . ja v a2 s . c om String credentials = FileUtils.readFileToString(new File(filename)); return credentials.replace("\n", ""); } catch (IOException e) { throw new IllegalStateException("Could not read credentials file: " + filename, e); } }
From source file:eu.seaclouds.platform.dashboard.utils.TestUtils.java
public static String getStringFromPath(String filePath) throws IOException { URL resource = Resources.getResource(filePath); return FileUtils.readFileToString(new File(resource.getFile())); }
From source file:com.github.cc007.buildoffmanagermaven.utils.PersistencyHelper.java
public static boolean loadBuildOff() { BuildOff bo = null;//from w w w .ja v a 2s . com boolean success = false; try { File boFile = new File(BuildOffManager.getPlugin().getDataFolder(), "BuildOff.json"); if (boFile.exists()) { String boString = FileUtils.readFileToString(boFile); Gson gson = new GsonBuilder().registerTypeAdapter(Location.class, new LocationAdapter()).create(); bo = gson.fromJson(boString, BuildOff.class); success = true; } } catch (IOException ex) { Logger.getLogger(PersistencyHelper.class.getName()).log(Level.SEVERE, null, ex); } BuildOffManager.getPlugin().setActiveBuildOff(bo); return success; }
From source file:ca.craigthomas.visualclassifier.dataset.DataSetReader.java
/** * Read from a CSV file, and return the samples as a list of doubles. * // w ww . jav a 2s.com * @param filename the name of the file to read from * @return the list of samples from the file * @throws IOException */ public static List<List<Double>> readCSVFile(String filename) throws IOException { File file = new File(filename); String fileContents = FileUtils.readFileToString(file); Reader reader = new StringReader(fileContents); CSVFormat format = CSVFormat.EXCEL; CSVParser parser = new CSVParser(reader, format); List<CSVRecord> records = parser.getRecords(); List<List<Double>> inputs = new ArrayList<List<Double>>(); for (CSVRecord record : records) { List<Double> inputLine = new ArrayList<Double>(); for (int index = 0; index < record.size(); index++) { String value = record.get(index); inputLine.add(Double.parseDouble(value)); } inputs.add(inputLine); } parser.close(); return inputs; }
From source file:com.contentful.vault.compiler.lib.TestUtils.java
public static String readTestResource(String fileName) throws IOException { URL resource = TestUtils.class.getClassLoader().getResource(fileName); return FileUtils.readFileToString(new File(resource.getPath())); }
From source file:com.flipkart.poseidon.serviceclients.idl.reader.IDLReader.java
public static ServiceIDL getIDL(String filePath) throws IOException { String json = FileUtils.readFileToString(new File(filePath)); return convertToIDL(json); }
From source file:bench.fix_openfast.RegistryFIX.java
public static TemplateRegistry makeTemplateRegistry(final File file) throws Exception { String text;//ww w . j a va2s. c om text = FileUtils.readFileToString(file); return makeTemplateRegistry(text); }
From source file:com.thoughtworks.go.config.GuidService.java
public static String loadGuid() { try {/* w w w .j a v a2 s .co m*/ return FileUtils.readFileToString(AGENT_GUID_FILE).trim(); } catch (IOException ioe) { throw bomb("Couldn't load GUID from filesystem", ioe); } }
From source file:cloudRessourceBase.DataUtil.java
public static String fileToString(File aFile) throws IOException { String fileContent = FileUtils.readFileToString(aFile); return fileContent; }
From source file:com.ebay.logstorm.core.compiler.PipelineCompiler.java
public static Pipeline compile(File file) throws IOException, PipelineException { return compileConfigString(FileUtils.readFileToString(file)); }