List of usage examples for org.apache.commons.io IOUtils toString
public static String toString(byte[] input) throws IOException
byte[]
as a String using the default character encoding of the platform. From source file:com.vaadin.tests.server.LicenseInJavaFiles.java
private void checkForLicenseInFile(File f, HashSet<String> missing) throws IOException { String contents = IOUtils.toString(new FileInputStream(f)); if (!contents.contains("@" + "VaadinApache2LicenseForJavaFiles" + "@")) { missing.add(f.getPath());//from www .ja va2 s . c o m } }
From source file:com.nebel_tv.content.utils.ConnectionUtils.java
/** * * @param url/*w w w . j a v a2s . c o m*/ * @return * @throws Exception */ public static String getResponseAsString(String url) throws Exception { if (ids.empty()) { init(); } String developerId = ids.pop(); try { url = url + "&Developerid=" + developerId; String result = IOUtils.toString(new URL(url)); ids.push(developerId); return result; } catch (MalformedURLException ex) { Logger.getLogger(ConnectionUtils.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ConnectionUtils.class.getName()).log(Level.WARNING, null, ex); } return null; }
From source file:net.feed_the_beast.launcher.json.JsonFactory.java
public static Update getUpdate(String name, String url) throws IOException { Library l = new Library(); l.name = name;/*from w w w . j a v a 2 s. com*/ return GSON.fromJson(IOUtils.toString(new URL(url + l.getPath())), Update.class); }
From source file:mujava.cli.Util.java
static String loadConfig() throws IOException { FileInputStream inputStream = new FileInputStream("mujavaCLI.config"); String input = IOUtils.toString(inputStream); String[] inputs = input.split("\n"); String path = new String(); if (inputs.length == 1) // only one line of configuration {/* ww w.j a va 2 s. c o m*/ path = inputs[0]; path = path.replace("MuJava_HOME=", ""); path = path.replace("\n", ""); } else if (inputs.length == 2) // 2 lines of configuration { path = inputs[0]; String debug = inputs[1]; path = path.replace("MuJava_HOME=", ""); path = path.replace("\n", ""); debug = debug.replace("Debug_mode=", ""); debug = debug.replace("\n", ""); // load debug mode from config file, and set it if (debug.equals("true")) Util.debug = true; else { Util.debug = false; } } inputStream.close(); return path; }
From source file:com.sequenceiq.ambari.shell.support.TableRendererTest.java
@Test public void testRenderMultiValueMap() throws IOException { Map<String, List<String>> map = new HashMap<String, List<String>>(); map.put("HDFS", Collections.singletonList("DATANODE")); map.put("MAPREDUCE2", Collections.singletonList("HISTORYSERVER")); map.put("ZOOKEEPER", Collections.singletonList("ZOOKEEPER_SERVER")); assertEquals(IOUtils.toString(new FileInputStream(new File("src/test/resources/2columns"))), TableRenderer.renderMultiValueMap(map, "SERVICE", "COMPONENT")); }
From source file:name.martingeisse.webide.features.java.compiler.classpath.ReadOnlyRegularFileObject.java
@Override public CharSequence getCharContent(final boolean ignoreEncodingErrors) throws IOException { final Reader r = openReader(ignoreEncodingErrors); final String content = IOUtils.toString(r); r.close();// ww w .j a va 2 s. c o m return content; }
From source file:com.opengamma.integration.marketdata.manipulator.dsl.SimulationScript.java
private void initialize() { InputStream scriptStream = SimulationScript.class.getResourceAsStream("InitializeScript.groovy"); try {/*from ww w . j av a 2 s . com*/ evaluate(IOUtils.toString(scriptStream)); } catch (IOException e) { throw new OpenGammaRuntimeException("Failed to initialize DSL script", e); } }
From source file:com.betfair.tornjak.monitor.active.url.CheckResponseContains.java
public void check(URLConnection urlConnection) throws Exception { InputStream inputStream = urlConnection.getInputStream(); String response = IOUtils.toString(inputStream); if (!response.contains(expectedString)) { throw new RuntimeException( String.format("Service reports [%s], which NOT contains [%s]", response, expectedString)); }//from w w w .ja v a 2s .c om }
From source file:com.collective.celos.ci.testing.fixtures.convert.ConversionCreatorTest.java
@Test public void testConversionCreatorForFile() throws Exception { FixObjectCreator<FixFile> creator = Utils.wrap(new FixFile(IOUtils.toInputStream("lowercase"))); AbstractFixObjectConverter<FixFile, FixFile> fixObjectConverter = new UpperCaseStringFixFileConverter(); ConversionCreator<FixFile, FixFile> conversionCreator = new ConversionCreator(creator, fixObjectConverter); FixFile result = conversionCreator.create(null); Assert.assertEquals("LOWERCASE", IOUtils.toString(result.getContent())); }
From source file:au.org.ala.bhl.WordListTests.java
@Test public void testDetectLanguage1() throws Exception { InputStream is = TaxonGrabTest.class.getResourceAsStream("/sample2.txt"); String text = IOUtils.toString(is); LanguageScore lang = WordLists.detectLanguage(text, "english"); System.out.println(lang);//from w w w . j a va2 s. co m }