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.properned.application.HelpController.java
public void initialize() { logger.info("Initialize help controller"); URL url = this.getClass().getResource("/com/properned/help/help.html"); String content;//from www. j a va 2s . c o m try { // content = IOUtils.toString(new FileInputStream(url.getFile())); content = IOUtils.toString(this.getClass().getResourceAsStream("/com/properned/help/help.html")); webView.getEngine().loadContent(content); } catch (IOException e) { Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.load.help"), e); } }
From source file:net.chuzarski.crowdednews.activities.LicenseActivity.java
private String readLicenses() { InputStream file = null;/* w w w . java2 s . c o m*/ String license; try { file = getAssets().open("LICENSES.txt"); license = IOUtils.toString(new BufferedInputStream(file)); file.close(); } catch (IOException e) { return "Licenses are broken"; } return license; }
From source file:com.gooddata.gdc.DataStoreServiceIT.java
@Test public void shouldUploadWithFullStagingLink() throws Exception { final String gdcBody = IOUtils.toString(readFromResource("/gdc/gdc.json")).replaceAll("/uploads", "http://localhost:" + port() + "/uploads"); onRequest().havingMethodEqualTo("GET").havingPathEqualTo("/gdc").respond().withBody(gdcBody) .withStatus(200);/* ww w. j a v a2 s . c o m*/ gd.getDataStoreService().upload("/test", content); }
From source file:com.sketchy.server.ServletAction.java
public static String getResponseBody(HttpServletRequest request) throws IOException { return IOUtils.toString(request.getInputStream()); }
From source file:com.frostwire.android.gui.dialogs.TermsUseDialog.java
private static String readText(Context context) { InputStream in = context.getResources().openRawResource(R.raw.tos); try {//from ww w. j a v a 2 s . c o m return IOUtils.toString(in); } catch (IOException e) { throw new RuntimeException("Missing TOS resource", e); } finally { IOUtils.closeQuietly(in); } }
From source file:com.h3xstream.findbugs.cli.FsbCommandLineLauncher.java
public void start(String[] args) throws IOException, InterruptedException, PluginException { if (!CheckBcel.check()) { System.exit(1);/*from ww w . j a v a 2 s . c o m*/ } System.out.println(IOUtils.toString(getClass().getResourceAsStream("banner.txt"))); FindBugs2 findBugs = new FindBugs2(); TextUICommandLine commandLine = new TextUICommandLine(); //Some specific initialisation FindSecBugsGlobalConfig.getInstance().setPrintCustomInjectionWarning(false); //Inject default arguments List<String> newArgs = new ArrayList<String>(); newArgs.addAll(Arrays.asList(args)); if (!newArgs.contains("-verbose")) newArgs.add(0, "-quiet"); //Process arguments FindBugs.processCommandLine(commandLine, newArgs.toArray(new String[newArgs.size()]), findBugs); boolean justPrintConfiguration = commandLine.justPrintConfiguration(); if (!justPrintConfiguration && !commandLine.justPrintVersion()) { //Actual execution FindBugs.runMain(findBugs, commandLine); } else { //Informational Version.printVersion(justPrintConfiguration); System.out.println("FindSecurityBugs " + FindSecBugsGlobalConfig.getInstance().getFindSecBugsVersion()); } }
From source file:com.cloudant.mazha.HttpRequestsTest.java
@Test public void get_resourceExist_success() throws Exception { URI allDbUri = this.uriHelper.allDbsUri(); InputStream is = client.get(allDbUri); Assert.assertNotNull(is);/*from www.ja va 2s . co m*/ String s = IOUtils.toString(is); Assert.assertTrue(s.contains(TEST_DB)); }
From source file:com.groupon.jenkins.dynamic.buildconfiguration.EffectiveBuildConfigurationCalculator.java
private static String readFile(String ymlResource) { InputStream base = null;/* ww w. ja va2s . com*/ try { base = EffectiveBuildConfigurationCalculator.class.getResourceAsStream(ymlResource); return IOUtils.toString(base); } catch (IOException e) { throw new RuntimeException(e); } finally { IOUtils.closeQuietly(base); } }
From source file:com.srcclr.jenkins.installer.SrcclrUpdateSite.java
private static String getSiteCert() { try {/*from w ww .j a v a 2s . c om*/ return IOUtils .toString(SrcclrUpdateSite.class.getResourceAsStream("/" + PROPERTIES.get("srcclr.site.ca"))); } catch (IOException ex) { LOGGER.error("Couldn't find site cert", ex); } return ""; }
From source file:external.PegdownController.java
@Route(method = HttpMethod.POST, uri = "/pegdown") public Result pegdown(@HttpParameter Reader markown) throws IOException { String md = IOUtils.toString(markown); return ok(processor.markdownToHtml(md)).html(); }