List of usage examples for java.io IOException toString
public String toString()
From source file:eionet.gdem.conversion.converters.PDFConverter.java
@Override public String convert(InputStream source, InputStream xslt, OutputStream result, String cnvFileExt) throws GDEMException, Exception { String pdfFile = Utils.getUniqueTmpFileName(".pdf"); if (result != null) { runFOPTransformation(source, xslt, result); } else {//from w w w .ja va 2 s . co m try { result = new FileOutputStream(pdfFile); runFOPTransformation(source, xslt, result); } catch (IOException e) { throw new GDEMException("Error creating PDF output file " + e.toString(), e); } finally { IOUtils.closeQuietly(result); } } return pdfFile; }
From source file:eionet.gdem.conversion.converters.XMLConverter.java
@Override public String convert(InputStream source, InputStream xslt, OutputStream result, String cnvFileExt) throws GDEMException, Exception { String xmlFile = Utils.getUniqueTmpFileName("." + cnvFileExt); if (result != null) { runXslTransformation(source, xslt, result); } else {/*from ww w . j a v a 2s. co m*/ try { result = new FileOutputStream(xmlFile); runXslTransformation(source, xslt, result); } catch (IOException e) { throw new GDEMException("Error creating XML output file " + e.toString(), e); } finally { IOUtils.closeQuietly(result); } } return xmlFile; }
From source file:eionet.gdem.conversion.converters.HTMLConverter.java
@Override public String convert(InputStream source, InputStream xslt, OutputStream result, String cnvFileExt) throws GDEMException, Exception { String htmlFile = Utils.getUniqueTmpFileName(".html"); if (result != null) { runXslTransformation(source, xslt, result); } else {// w w w . java2 s . c om try { result = new FileOutputStream(htmlFile); runXslTransformation(source, xslt, result); } catch (IOException e) { throw new GDEMException("Error creating HTML output file " + e.toString(), e); } finally { IOUtils.closeQuietly(result); } } return htmlFile; }
From source file:eionet.gdem.conversion.converters.TextConverter.java
@Override public String convert(InputStream source, InputStream xslt, OutputStream result, String cnvFileExt) throws GDEMException, Exception { String outFile = Utils.getUniqueTmpFileName("." + cnvFileExt); if (result != null) { runXslTransformation(source, xslt, result); } else {//from w w w. j av a 2 s. com try { result = new FileOutputStream(outFile); runXslTransformation(source, xslt, result); } catch (IOException e) { throw new GDEMException("Error creating TEXT output file:" + e.toString(), e); } finally { IOUtils.closeQuietly(result); } } return outFile; }
From source file:CookieMIDlet.java
public void run() { String url = getAppProperty("CookieMIDlet-URL"); try {//from w w w .java 2s .c om HttpConnection hc = (HttpConnection) Connector.open(url); if (mSession != null) hc.setRequestProperty("cookie", mSession); InputStream in = hc.openInputStream(); String cookie = hc.getHeaderField("Set-cookie"); if (cookie != null) { int semicolon = cookie.indexOf(';'); mSession = cookie.substring(0, semicolon); } int length = (int) hc.getLength(); byte[] raw = new byte[length]; in.read(raw); String s = new String(raw); Alert a = new Alert("Response", s, null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); in.close(); hc.close(); } catch (IOException ioe) { Alert a = new Alert("Exception", ioe.toString(), null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); } }
From source file:CookieMIDlet.java
private void send() { String url = "http://localhost/http.asp"; try {/*from w ww . j a v a 2 s . c o m*/ HttpConnection hc = (HttpConnection) Connector.open(url); if (mSession != null) hc.setRequestProperty("cookie", mSession); InputStream in = hc.openInputStream(); String cookie = hc.getHeaderField("Set-cookie"); if (cookie != null) { int semicolon = cookie.indexOf(';'); mSession = cookie.substring(0, semicolon); } int length = (int) hc.getLength(); byte[] raw = new byte[length]; in.read(raw); String s = new String(raw); Alert a = new Alert("Response", s, null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); in.close(); hc.close(); } catch (IOException ioe) { Alert a = new Alert("Exception", ioe.toString(), null, null); a.setTimeout(Alert.FOREVER); mDisplay.setCurrent(a, mForm); } }
From source file:com.cura.Terminal.Terminal.java
public synchronized String ExecuteCommand(String command) { try {// www .j av a2s . com channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand(command); channel.connect(); // get output from server in = channel.getInputStream(); // convert output to string writer.getBuffer().setLength(0); IOUtils.copy(in, writer); result = writer.toString(); System.gc(); } catch (IOException i) { Log.d("terminal", i.toString()); } catch (JSchException e) { // TODO Auto-generated catch block Log.d("terminal", e.toString()); } return result; }
From source file:net.oletalk.hellospringboot.controller.HelloController.java
@PostMapping("/upload") public String handleFileUpload(@RequestParam("file") MultipartFile file, RedirectAttributes attributes) { // multipart file upload is slightly different String originalName = file.getOriginalFilename(); // TODO any way of getting files uploaded without transferring to a temp file? // It seems to want to know the complete path but MultipartFile doesn't give us that. String returnMsg;/*from w w w . ja va2 s . c o m*/ try { LOG.info("Creating temp file for upload"); File tmpFile = File.createTempFile("s3upload", null); tmpFile.deleteOnExit(); file.transferTo(tmpFile); returnMsg = s3service.uploadDocument("test/" + originalName, tmpFile); attributes.addFlashAttribute("message", returnMsg); } catch (IOException ioe) { LOG.error("Error creating temp file for upload:" + ioe.toString()); attributes.addFlashAttribute("message", "Problem preparing upload to S3"); } return "redirect:/hello/doc/"; }
From source file:hochschuledarmstadt.photostream_tools.StoreCommentAsyncTask.java
@Override protected Comment doInBackground(Void... params) { try {/* w w w . j av a2 s .c o m*/ return sendComment(); } catch (IOException e) { Logger.log(TAG, LogLevel.ERROR, e.toString()); postError(new HttpError(-1, e.toString())); } catch (HttpPhotoStreamException e) { Logger.log(TAG, LogLevel.ERROR, e.toString()); postError(e.getHttpError()); } return null; }
From source file:eu.morfeoproject.fast.catalogue.recommender.FPGrowth.java
public TopKStringPatterns getTopKFrequentPatterns(String feature) { try {/*from w w w .j av a2 s . c o m*/ String output = params.get("output", "fpgrowth-output.dat"); Path path = new Path(output); FileSystem fs = FileSystem.get(this.conf); List<Pair<String, TopKStringPatterns>> frequentPatterns = org.apache.mahout.fpm.pfpgrowth.fpgrowth.FPGrowth .readFrequentPattern(fs, conf, path); for (Pair<String, TopKStringPatterns> entry : frequentPatterns) { if (entry.getFirst().equals(feature)) return entry.getSecond(); } } catch (IOException e) { log.error(e.toString(), e); } return null; }