List of usage examples for org.apache.wicket.util.io IOUtils toString
public static String toString(final InputStream input, final String encoding) throws IOException
InputStream
as a String using the specified character encoding. From source file:com.googlecode.refit.web.EditPage.java
License:Open Source License
private void loadText() { try {//from w w w .j a va2 s . com htmlText = IOUtils.toString(new FileInputStream(inputFileName), "UTF-8"); } catch (IOException exc) { throw new RuntimeException(exc); } }
From source file:fiftyfive.wicket.test.BaseValidatorTest.java
License:Apache License
protected AbstractDocumentValidator validator(String resource) throws IOException { InputStream in = null;// w ww . j ava2 s. co m try { in = getClass().getResourceAsStream(resource); String doc = IOUtils.toString(in, "UTF-8"); AbstractDocumentValidator validator = createValidator(); validator.parse(doc); return validator; } finally { IOUtils.closeQuietly(in); } }
From source file:org.onexus.ui.authentication.persona.VerifyBehavior.java
License:Apache License
private String verify(final String assertion, final String audience) { String failureReason = null;/*from ww w . j a va2 s .com*/ try { URL verifyUrl = new URL("https://verifier.login.persona.org/verify"); URLConnection urlConnection = verifyUrl.openConnection(); urlConnection.setDoOutput(true); OutputStream outputStream = urlConnection.getOutputStream(); String postParams = "assertion=" + assertion + "&audience=" + audience; outputStream.write(postParams.getBytes()); outputStream.close(); String response = IOUtils.toString(urlConnection.getInputStream(), "UTF-8"); BrowserId browserId = BrowserId.of(response); if (browserId != null) { if (BrowserId.Status.OK.equals(browserId.getStatus())) { SessionHelper.logIn(Session.get(), browserId); } else { failureReason = browserId.getReason(); } } } catch (IOException e) { failureReason = e.getMessage(); } return failureReason; }