List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:org.kitodo.sruimport.ResponseHandler.java
/** * Transform given HttpResponse into Document and return it. * @param response HttpResponse that is transformed into a Document * @return Document into which given HttpResponse has been transformed *///from www . j a va 2s. co m static Document transformResponseToDocument(HttpResponse response) { HttpEntity entity = response.getEntity(); if (Objects.nonNull(entity)) { try { return parseXML(entity.getContent()); } catch (IOException e) { throw new ConfigException(e.getMessage()); } } throw new ConfigException("SRU response is null"); }
From source file:com.arrggh.eve.api.sde.StaticDataExportImporter.java
private static <T> T processMap(String what, InputStream inputStream, TypeReference<T> typeReference) throws IOException { String yaml = IOUtils.toString(inputStream, "utf-8"); try {/*from w w w . j a v a 2s .c om*/ T result = mapper.readValue(yaml, typeReference); return result; } catch (IOException e) { System.out.println("Error loading " + what + ":" + e.getMessage()); // System.out.println(yaml); throw e; } }
From source file:com.arrggh.eve.api.sde.StaticDataExportImporter.java
private static <T> List<T> processArray(String what, InputStream inputStream, TypeReference<T[]> typeReference) throws IOException { String yaml = IOUtils.toString(inputStream, "utf-8"); try {/*www. j a v a2 s . c o m*/ T[] result = mapper.readValue(yaml, typeReference); return Arrays.asList(result); } catch (IOException e) { System.out.println("Error loading " + what + ":" + e.getMessage()); // System.out.println(yaml); throw e; } }
From source file:fr.paris.lutece.plugins.updater.util.sql.SqlUtils.java
/** * Executes a SQL script file//from ww w . j av a 2 s .co m * @param strFilename The filename * @param plugin The plugin * @throws IOException If an IO exception occurs * @throws SQLException If an SQL exception occurs */ public static void executeSqlFileScript(String strFilename, Plugin plugin) throws IOException, SQLException { try { File file = new File(strFilename); String strScript = FileUtils.readFileToString(file); executeSqlScript(strScript, plugin); } catch (IOException ex) { AppLogService.error("updater - execute SQL script error : " + ex.getMessage(), ex); throw ex; } }
From source file:org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTUtil.java
public static String getResponseString(HttpResponse httpResponse) throws IOException { BufferedReader br = null;//w w w .j a va 2 s .co m try { br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent())); String readLine; String response = ""; while (((readLine = br.readLine()) != null)) { response += readLine; } return response; } finally { EntityUtils.consumeQuietly(httpResponse.getEntity()); if (br != null) { try { br.close(); } catch (IOException e) { log.warn("Error while closing the connection! " + e.getMessage()); } } } }
From source file:com.github.megatronking.svg.cli.Main.java
private static void svg2vectorForFile(File inputFile, File outputFile, int width, int height) { if (inputFile.getName().endsWith(".svgz")) { File tempUnzipFile = new File(inputFile.getParent(), FileUtils.noExtensionLastName(inputFile) + ".svg"); try {//from www. j a va 2 s. c o m FileUtils.unZipGzipFile(inputFile, tempUnzipFile); svg2vectorForFile(tempUnzipFile, outputFile, width, height); } catch (IOException e) { throw new RuntimeException("Unzip file occur an error: " + e.getMessage()); } finally { tempUnzipFile.delete(); } } else if (inputFile.getName().endsWith(".svg")) { Svg2Vector.parseSvgToXml(inputFile, outputFile, width, height); } }
From source file:net.rim.ejde.internal.util.RIAUtils.java
public static void initDLLs() { IPath dllStoreLocation = ContextManager.PLUGIN.getStateLocation().append("installDlls"); //$NON-NLS-1$ File dllStoreFile = dllStoreLocation.toFile(); if (!dllStoreFile.exists()) dllStoreFile.mkdir();//from www . j ava 2 s. co m InputStream inputStream; OutputStream outputStream; File dllFile; byte[] buf; int numbytes; URL bundUrl; for (String dllFileName : dllNames) { inputStream = null; outputStream = null; try { dllFile = dllStoreLocation.append(dllFileName).toFile(); Bundle bundle = ContextManager.PLUGIN.getBundle(); if (!dllFile.exists() || bundle.getLastModified() > dllFile.lastModified()) { bundUrl = bundle.getResource(dllFileName); if (bundUrl == null) continue; inputStream = bundUrl.openStream(); outputStream = new FileOutputStream(dllFile); buf = new byte[4096]; numbytes = 0; while ((numbytes = inputStream.read(buf)) > 0) outputStream.write(buf, 0, numbytes); } } catch (IOException t) { _log.error(t.getMessage(), t); } finally { try { if (inputStream != null) inputStream.close(); if (outputStream != null) outputStream.close(); } catch (IOException t) { _log.error(t.getMessage(), t); } } } // end for }
From source file:com.hp.test.framework.Reporting.cleanTempDir.java
public static void cleanandCreate(String Reports_path, int last_run) { String temp_path = Reports_path + "\\temp"; deleteDir(new File(temp_path)); File file = new File(temp_path); boolean isDirectoryCreated = file.mkdir(); if (isDirectoryCreated) { log.info("successfully Created directory"); } else {/*from w w w . ja v a2 s .co m*/ file.delete(); file.mkdir(); log.info("deleted and Created directory"); } File trgDir = new File(temp_path); File srcDir = new File(Reports_path); try { FileUtils.copyDirectory(srcDir, trgDir); log.info("Copying reports to temp path is completed"); } catch (IOException ex) { log.error("Issue with the copying reports to temp directory" + ex.getMessage()); } try { removerunlinks.removelinksforpreRuns(temp_path + "\\results\\", "ConsolidatedPage.html", last_run); } catch (IOException ex) { log.error("Error in removing links from the page ConsolidatedPage.html" + ex.getMessage()); } for (int i = 1; i < last_run; i++) { try { deleteDir(new File(temp_path + "\\results\\Run_" + i)); } catch (Exception ex) { log.error("Not able to delete directory" + temp_path + "\\results\\Run_" + i); } log.error("Deleted" + temp_path + "\\results\\Run_" + i); } FileUtils.deleteQuietly(new File(temp_path + "\\ISTF_Reports.zip")); // ZipUtils.ZipFolder(temp_path, Reports_path+); }
From source file:it.cnr.ilc.tokenizer.utils.Utilities.java
public static String readFileContent(String filepath) throws IOException { String message = ""; File initialFile;/*from ww w . ja v a 2 s . com*/ InputStream targetStream = null; String theString = ""; try { initialFile = new File(filepath); targetStream = FileUtils.openInputStream(initialFile); theString = IOUtils.toString(targetStream, "UTF-8"); } catch (IOException e) { message = "IOaaException in reading the stream for " + filepath + " " + e.getMessage(); Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, message); //System.exit(-1); } finally { if (targetStream != null) { try { targetStream.close(); } catch (IOException e) { message = "IOException in closing the stream for " + filepath + " " + e.getMessage(); Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, message); //System.exit(-1); } } } //System.err.println(theString); return theString; }
From source file:IO.serializer.java
public static void Serialize(Object object, String destinationFilename) { String serializedFilename = String.format("%s\\%s.%s", m_systemTempDirectory, destinationFilename, m_serializedFileExtension);// w w w . j a v a 2 s . c o m try (FileOutputStream fos = new FileOutputStream(serializedFilename)) { ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object); oos.close(); } catch (IOException ex) { Console.PrintLine( String.format("Error serilizing object '%s': %s", destinationFilename, ex.getMessage()), true, false); } }