List of usage examples for java.io IOException toString
public String toString()
From source file:org.callimachusproject.auth.OpenIDAuthReader.java
@Override public String getParameters(String method, String uri, String query, HttpEntity body) { if ("POST".equals(method) && body != null && body.getContentType() != null && "application/x-www-form-urlencoded".equals(body.getContentType().getValue())) { try {/* w ww . j a v a 2s . c o m*/ return EntityUtils.toString(body); } catch (IOException e) { logger.warn(e.toString(), e); } } return query; }
From source file:BwaAlignmentBase.java
public ArrayList<String> copyResults(String outputSamFileName) { ArrayList<String> returnedValues = new ArrayList<String>(); String outputDir = this.bwaInterpreter.getOutputHdfsDir(); Configuration conf = new Configuration(); try {/*from w ww. j a v a2 s.c o m*/ FileSystem fs = FileSystem.get(conf); fs.copyFromLocalFile(new Path(this.bwaInterpreter.getOutputFile()), new Path(outputDir + "/" + outputSamFileName)); // Delete the old results file File tmpSamFullFile = new File(this.bwaInterpreter.getOutputFile()); tmpSamFullFile.delete(); } catch (IOException e) { e.printStackTrace(); this.LOG.error(e.toString()); } returnedValues.add(outputDir + "/" + outputSamFileName); return returnedValues; }
From source file:cz.incad.kramerius.client.CacheServlet.java
private void loadFromFile(HttpServletRequest req, HttpServletResponse resp) throws IOException { try {// w ww . j a v a 2s. c om String filename = getPath() + req.getParameter("f"); File f = new File(filename); resp.getWriter().write(FileUtils.readFileToString(f, "UTF-8")); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Could not load file: " + e.toString()); } }
From source file:name.martingeisse.trading_game.platform.util.logging.MyLayout.java
@Override public String toSerializable(LogEvent event) { try {/*from w w w . java 2 s.c o m*/ StringBuilder builder = getStringBuilder(); PipeEscaper pipeEscaper = new PipeEscaper(builder); // timestamp, thread name, logger name TIMESTAMP_FORMATTER.printTo(builder, event.getTimeMillis()); builder.append(" | "); pipeEscaper.append(event.getThreadName()); builder.append(" | "); pipeEscaper.append(event.getLoggerName()); builder.append(" | "); // context map Map<String, String> contextMap = event.getContextMap(); if (contextMap != null && !contextMap.isEmpty()) { gson.toJson(contextMap, pipeEscaper); builder.append(" | "); } else { builder.append("| "); } // context stack ContextStack contextStack = event.getContextStack(); if (contextStack != null && !contextStack.isEmpty()) { gson.toJson(contextStack, pipeEscaper); builder.append(" | "); } else { builder.append("| "); } // level builder.append(event.getLevel()); builder.append(" | "); // message pipeEscaper.append(event.getMessage().getFormattedMessage()); // exception printException(builder, event.getThrown()); printException(builder, event.getMessage().getThrowable()); // end of record if (useParagraphSeparator) { builder.append((char) 8233); // paragraph separator } builder.append('\n'); return builder.toString(); } catch (IOException e) { return e.toString(); } }
From source file:com.photon.phresco.nativeapp.unit.test.testcases.H_LoginActivityTest.java
/** * send valid login email id and password to web server * *///from ww w .j ava 2 s. co m @Test public final void testLogin() { JSONObject jObjMain = new JSONObject(); JSONObject jObj = new JSONObject(); try { PhrescoLogger.info(TAG + " testLogin -------------- START "); jObj.put("loginEmail", "tester@phresco.com"); jObj.put("password", "123"); jObjMain.put("login", jObj); JSONObject responseJSON = null; responseJSON = JSONHelper.postJSONObjectToURL( Constants.getWebContextURL() + Constants.getRestAPI() + Constants.LOGIN_POST_URL, jObjMain.toString()); assertNotNull("Login response is not null", responseJSON.length() > 0); PhrescoLogger.info(TAG + " testLogin -------------- END "); } catch (IOException ex) { PhrescoLogger.info(TAG + " - testLogin - IOException : " + ex.toString()); PhrescoLogger.warning(ex); } catch (JSONException ex) { PhrescoLogger.info(TAG + " - testLogin - JSONException : " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:cz.incad.kramerius.client.CacheServlet.java
private void saveToFile(HttpServletRequest req, HttpServletResponse resp) throws IOException { try {//from www . j a va 2s.c o m String filename = getPath() + req.getParameter("f"); String content = req.getParameter("c"); File f = new File(filename); FileUtils.writeStringToFile(f, content, "UTF-8"); resp.getWriter().write("File saved"); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Could not save file: " + e.toString()); } }
From source file:info.pancancer.arch3.jobGenerator.JobGenerator.java
private Map<String, String> parseIniFile(String iniFile) { Map<String, String> iniHash = new LinkedHashMap<>(); try {//from w w w . j a v a 2 s .c o m IniFile ini = new IniFile(iniFile); iniHash = ini.getEntries().get("no-section"); } catch (IOException e) { log.error(e.toString()); } return iniHash; }
From source file:com.rptools.io.TableFileParser.java
/** * Parse file found at path {@param file} into an RPTable object. See {@link * RPTable} for expected table file format. * * Json files are read directly as a proto3 RPTable message. Text files must * be parsed, have their json equivalent written, then deleted. This is to * ease adding future tables by pasting their text content instead of trying * to convert them to json by hand./*w w w.j a v a 2s . c o m*/ * * @param file Input table text/json file. * @return {@link RPTable.Builder} created from contents of input file. */ public RPTable.Builder parseFile(Path file) { roll = 1; try { List<String> lines = Files.readAllLines(file); RPTable.Builder builder = RPTable.newBuilder(); // We want to keep json files around, and convert text files to json, then delete them. if (file.getFileName().toString().endsWith(EXT_JSON)) { JsonFormat.parser().merge(JOINER.join(lines), builder); return builder; } setTableName(file, builder); String headerRow = lines.remove(0); List<String> headers = SPLITTER.splitToList(headerRow); builder.addAllColumns(headers); lines.forEach(line -> parseLine(builder, headers, line)); // only return a table for .txt files if the json file did not also // already exist to be read separately if (updateResourceFiles(file, builder)) { return builder; } log.debug("Not renewing json/text file"); return null; } catch (IOException e) { log.error(String.format(PARSE_ERROR, file.toString(), e.toString()), e); return null; } }
From source file:net.bcsw.sdnwlan.web.SDNWLANResource.java
/** * Create a new sdnWLAN Access Point/*from ww w . j a v a 2s . c o m*/ * * @param stream input stream * @return response to the request */ @POST @Path("add") public String accessPointAddNotification(InputStream stream) { log.info("Received sdnWLAN Access Point create request"); if (stream == null) { log.info("Parameters can not be null"); return ""; } APManager sdnwlanService = get(APManager.class); try { AccessPointConfig entry = jsonToAccessPoint(stream); // Create the access point (TODO Look into what we want to return) //String returnData = sdnwlanService.createAccessPoint(entry); String returnData = null; // TODO not yet supported if (returnData != null) { return returnData; } } catch (IOException e) { log.error("Failed to deserialize AccessPoint JSON {}", e.toString()); } return ""; }