List of usage examples for java.io FileNotFoundException getMessage
public String getMessage()
From source file:at.madexperts.logmynight.facebook.AsyncRequestListener.java
public void onFileNotFoundException(FileNotFoundException e) { Log.e("stream", "Resource not found:" + e.getMessage()); }
From source file:com.lhy.commons.encrypt.service.EncryptService.java
@Override public File createLicenseFile(License license, String licenseFilePath) { License licObj = new License(); licObj.setIpAddress(DigestUtils.sha512Hex(license.getIpAddress())); licObj.setLicenseID(license.getLicenseID()); licObj.setLicenseType(license.getLicenseType()); licObj.setStopTime(/* www . j a va 2 s . c o m*/ license.getStopTime() == null ? DateUtils.addDays(new Date(), 30) : license.getStopTime()); File licenseFile = null; try { licenseFile = new File(licenseFilePath + File.separator + LicenseFileName); ObjectOutput out = new ObjectOutputStream(new FileOutputStream(licenseFile)); out.writeObject(licObj); out.close(); } catch (FileNotFoundException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } return licenseFile; }
From source file:com.lhy.commons.encrypt.service.EncryptService.java
@Override public License getLicense(File licenseFile, String ipAddress) { License licFile = null;// w w w . ja va 2 s . c o m try { ObjectInput in = new ObjectInputStream(new FileInputStream(licenseFile)); licFile = (License) in.readObject(); if (licFile.getIpAddress().equals(DigestUtils.sha512Hex(ipAddress)) && licFile.getLicenseType().equals(LicenseType.user)) { licFile.setLicenseType(LicenseType.user); } else { licFile.setLicenseType(LicenseType.developer); } in.close(); } catch (FileNotFoundException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } catch (ClassNotFoundException e) { log.error(e.getMessage()); } return licFile; }
From source file:org.zilverline.extractors.TestExcelExtractor.java
public void testGetContentAsInputStream() { try {/* w w w. jav a2 s . co m*/ ExcelExtractor tex = new ExcelExtractor(); InputStream is = new FileInputStream("test\\data\\test.xls"); String txt = tex.getContent(is); assertNotNull(txt); log.debug(txt.trim()); assertTrue(txt.length() > 0); assertTrue(txt.trim().startsWith("2.0 1.0 zilverline test")); assertTrue(StringUtils.countOccurrencesOf(txt, "test") > 0); } catch (FileNotFoundException e) { fail(e.getMessage()); } }
From source file:com.web.controller.ToolController.java
@ResponseBody @RequestMapping(value = "/tool/verifyapk", method = RequestMethod.POST) public String verifyApk(@RequestParam("apkfile") MultipartFile file) { //keytool -list -printcert -jarfile d:\weixin653android980.apk //keytool -printcert -file D:\testapp\META-INF\CERT.RSA //System.out.println("12345"); try {// ww w.j a v a2s .co m OutputStream stream = new FileOutputStream(new File(file.getOriginalFilename())); BufferedOutputStream outputStream = new BufferedOutputStream(stream); outputStream.write(file.getBytes()); outputStream.flush(); outputStream.close(); Runtime runtime = Runtime.getRuntime(); String ccString = "keytool -list -printcert -jarfile C:\\Users\\Administrator\\Desktop\\zju1.1.8.2.apk"; Process p = runtime.exec(ccString); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); StringBuilder sb = new StringBuilder(); while (br.readLine() != null) { sb.append(br.readLine() + "<br/>"); } p.destroy(); p = null; return sb.toString(); } catch (FileNotFoundException fe) { return fe.getMessage(); } catch (IOException ioe) { return ioe.getMessage(); } }
From source file:edu.du.penrose.systems.fedoraApp.util.MetsBatchFileSplitter.java
/** * Split a file with multiple METS sections into separate files each containing * a single METS record. The input file must contain one or more multiple * <mets></mets> elements (sections). if true a OBJID must exist in every <mets> * element, this will become the file name. Otherwise a unique file name is * generated. Return true if the <batch update="true"> is set in the batch file other * wise return false (defaults to new file being ingested ). * /*www . j a va 2 s .c om*/ * @see edu.du.penrose.systems.fedoraApp.batchIngest.bus.BatchIngestThreadManager#setBatchSetStatus(String, String) * @param threadStatus this object receives status updates while splitting the file. * @param inFile file to split * @param metsNewDirectory directory containing METS for new objects. * @param metsUpdatesDirectory directory containing METS for existing objects. * @param nameFileFromOBJID if true a OBJID must exist in every <mets> element, this will become the file name. Otherwise a unique file name is * generated * @deprecated * @throws Exception on any IO error. */ static public void splitMetsBatchFile_version_1(BatchIngestOptions ingestOptions, ThreadStatusMsg threadStatus, File inFile, String metsNewDirectory, String metsUpdatesDirectory, boolean nameFileFromOBJID) throws FatalException { String metsDirectory = null; // will get set to either the new directory or the updates directory. FileInputStream batchFileInputStream; try { batchFileInputStream = new FileInputStream(inFile); } catch (FileNotFoundException e) { throw new FatalException(e.getMessage()); } DataInputStream batchFileDataInputStream = new DataInputStream(batchFileInputStream); BufferedReader batchFileBufferedReader = new BufferedReader( new InputStreamReader(batchFileDataInputStream)); File outFile = null; FileOutputStream metsFileOutputStream = null; BufferedWriter metsBufferedWriter = null; String oneLine = null; String documentType = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; int fileCount = 0; try { while (batchFileBufferedReader.ready()) { threadStatus.setStatus("Spliting XML file #: " + fileCount); oneLine = batchFileBufferedReader.readLine(); if (oneLine.contains("<?xml version")) { documentType = oneLine; } if (oneLine.contains("<batch")) { if (oneLine.contains(FedoraAppConstants.BATCH_FILE_UPDATE_MARKER + "=" + QUOTE + "true" + QUOTE) || oneLine.contains( FedoraAppConstants.BATCH_FILE_UPDATE_MARKER + "=" + APOST + "true" + APOST)) { ingestOptions.setBatchIsUpdates(true); metsDirectory = metsUpdatesDirectory; } else { ingestOptions.setBatchIsUpdates(false); metsDirectory = metsNewDirectory; } } if (oneLine.contains("<mets:mets")) { boolean haveEntireMetsLine = false; while (!haveEntireMetsLine) { StringBuffer tempBuffer = new StringBuffer(oneLine); String moreOfMetsLine = null; if (!oneLine.contains(">")) { moreOfMetsLine = batchFileBufferedReader.readLine(); tempBuffer.append(moreOfMetsLine); if (moreOfMetsLine.contains(">")) { haveEntireMetsLine = true; oneLine = tempBuffer.toString(); } else { oneLine = tempBuffer.toString(); } } else { haveEntireMetsLine = true; } } // Name the output file for a single Mets element and its contents. if (nameFileFromOBJID) { String objID = MetsBatchFileSplitter.getObjID(oneLine); outFile = new File(metsDirectory + objID + ".xml"); logger.info("outputSplitFile METS file: " + metsDirectory + objID + ".xml"); if (outFile.exists()) { String errorMsg = "OBJID already exists:" + outFile.getName(); System.out.println(errorMsg); logger.error(errorMsg); throw new FatalException(errorMsg); } } else { outFile = new File(metsDirectory + edu.du.penrose.systems.util.FileUtil.getDateTimeMilliSecondEnsureUnique() + ".xml"); } logger.info("outputSplitFile METS file: " + outFile.toString() + "\n\n"); metsFileOutputStream = new FileOutputStream(outFile); metsBufferedWriter = new BufferedWriter(new OutputStreamWriter(metsFileOutputStream, "UTF-8")); metsBufferedWriter.write(documentType); metsBufferedWriter.newLine(); // This is a version 1 batch file, so write a default version 2 command line for the new ingester metsBufferedWriter.write(FedoraAppConstants.VERSION_ONE_COMMAND_LINE); metsBufferedWriter.newLine(); while (!oneLine.contains("</mets:mets")) { // null pointer on premature end of file. metsBufferedWriter.write(oneLine); metsBufferedWriter.newLine(); oneLine = batchFileBufferedReader.readLine(); } metsBufferedWriter.write(oneLine); metsBufferedWriter.newLine(); metsBufferedWriter.close(); fileCount++; } } // while } catch (NullPointerException e) { String errorMsg = "Unable to split files, Permature end of file: Corrupt:" + inFile.toString() + " ?"; throw new FatalException(errorMsg); } catch (Exception e) { String errorMsg = "Unable to split files: " + e.getMessage(); logger.fatal(errorMsg); throw new FatalException(errorMsg); } finally { try { if (batchFileBufferedReader != null) { batchFileBufferedReader.close(); } if (metsBufferedWriter != null) { metsBufferedWriter.close(); } } catch (IOException e) { throw new FatalException(e.getMessage()); } } }
From source file:com.intel.cosbench.controller.handler.AbstractClientHandler.java
@Override public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception { String message = null;/*from w w w . j a va2s.c o m*/ try { message = process(req, res); } catch (BadRequestException bre) { message = "Bad Request"; } catch (NotFoundException nfe) { message = "Not Found"; } catch (IllegalStateException ise) { message = ise.getMessage(); } catch (ConfigException ce) { message = ce.getMessage(); } catch (FileNotFoundException fnfe) { message = fnfe.getMessage(); } catch (IOException ie) { message = ie.getMessage(); } catch (Exception e) { StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); message = "Internal Error\n" + writer.toString(); } return new ModelAndView(TEXT, "message", message); }
From source file:com.pullup.app.util.ImageUtils.java
public BufferedImage readImage(String token) { String path = "C:\\pullup\\profile\\" + token + ".png"; InputStream in = null;/*from ww w . j a va2 s . c o m*/ BufferedImage image = null; try { in = new FileInputStream(new File(path)); image = ImageIO.read(in); } catch (FileNotFoundException ex) { log.severe("Could not read image: " + ex.getMessage()); } catch (IOException ex) { log.severe("Could not read image: " + ex.getMessage()); } return image; }
From source file:net.ageto.gyrex.impex.common.steps.impl.readers.FileReaderSimple.java
@Override protected StatusStep process() { String filename = (String) getInputParam( FileReaderLineBasedDefinition.InputParamNames.INPUT_FILENAME.name()); if (StringUtils.isBlank(filename)) { processError("{0} missing input.", ID); return StatusStep.ERROR; }//w w w .java2 s . c om File f = new File(filename); byte[] buffer = new byte[(int) f.length()]; InputStream in; try { in = new FileInputStream(f); in.read(buffer); in.close(); } catch (FileNotFoundException e) { processError(e.getMessage()); return StatusStep.ERROR; } catch (IOException e) { processError(e.getMessage()); return StatusStep.ERROR; } setOutputParam(FileReaderLineBasedDefinition.OutputParamNames.OUTPUT_FILECONTENT.name(), new StringBuffer(new String(buffer))); processInfo("{0} has been completed successfully.", ID); return StatusStep.OK; }
From source file:com.comu.android.AsyncRequestListener.java
public void onFileNotFoundException(FileNotFoundException e, final Object state) { Log.e("stream", "Resource not found:" + e.getMessage()); }