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.linkedin.gradle.python.tasks.GenerateSetupPyTask.java
@TaskAction public void createSetupPy() throws IOException { File file = getProject().file("setup.py"); if (file.exists()) { logger.lifecycle("Contents of setup.py are going to be overwritten!!"); file.delete();/* w w w .j a va2 s. co m*/ } file.createNewFile(); String setupPy = IOUtils .toString(GenerateSetupPyTask.class.getResourceAsStream("/templates/setup.py.template")); FileUtils.write(file, setupPy); }
From source file:iotest.WriteToFileTest.java
@Test @Ignore/*from w w w . j a v a 2s . c om*/ public void printWorkingDIR() throws IOException { String[] cmd = { "/bin/bash", "-c", "cd /media/sf_FBDC_PROD; ls -l" }; Process p = Runtime.getRuntime().exec(cmd); String output = IOUtils.toString(p.getInputStream()); System.out.println(">>>>>>>>>>>" + output); }
From source file:edu.byui.firstproject.helloWorld.getPost.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from www . j av a2s . c om * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try { File file = new File("entry.txt"); if (!file.exists()) { file.createNewFile(); } FileInputStream inputStream = new FileInputStream("entry.txt"); String everything = IOUtils.toString(inputStream); String[] ss = everything.split("\n"); try (PrintWriter out = response.getWriter()) { for (int a = (ss.length - 1); a >= 0; a--) { String[] entry = ss[a].split("//"); out.println("<table width=\"400\" border=\"1\" cellpadding=\"10\">"); out.println("<tbody>"); out.println("<tr>"); out.println("<td>" + "Time : " + entry[0] + "</td>"); out.println("<td>" + "User : " + entry[1] + "</td>"); out.println("</tr>"); out.println("<tr>"); out.println("<td colspan = \"2\">" + "Entry : " + entry[2] + "</td>"); out.println("</tr>"); out.println("</tbody>"); out.println("</table>"); } out.println("<a href=forum.>Click here to return</a>"); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.ning.billing.account.dao.AccountDaoTestBase.java
@BeforeClass(alwaysRun = true) protected void setup() throws IOException { // Health check test to make sure MySQL is setup properly try {//w w w. j a v a 2 s . c o m module = new AccountModuleMock(); final String accountDdl = IOUtils .toString(AccountSqlDao.class.getResourceAsStream("/com/ning/billing/account/ddl.sql")); final String invoiceDdl = IOUtils .toString(AccountSqlDao.class.getResourceAsStream("/com/ning/billing/invoice/ddl.sql")); final String utilDdl = IOUtils .toString(AccountSqlDao.class.getResourceAsStream("/com/ning/billing/util/ddl.sql")); module.startDb(); module.initDb(accountDdl); module.initDb(invoiceDdl); module.initDb(utilDdl); final Injector injector = Guice.createInjector(Stage.DEVELOPMENT, module); dbi = injector.getInstance(IDBI.class); accountDao = injector.getInstance(AccountDao.class); accountDao.test(); EventBusService busService = injector.getInstance(EventBusService.class); ((DefaultEventBusService) busService).startBus(); } catch (Throwable t) { fail(t.toString()); } }
From source file:br.ufg.inf.es.fs.contpatri.persistencia.JsonUtil.java
public Object deInputStreamParaJson(InputStream inputStream) throws IOException { String json = IOUtils.toString(inputStream); Object objeto = gson.fromJson(json, Object.class); return objeto; }