Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

In this page you can find the example usage for java.io FileNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:export.notes.view.to.excel.ExportAction.java

/**
 * The action has been activated. The argument of the method represents the 'real' action
 * sitting in the workbench UI./*  w  w  w .  j ava  2 s.co m*/
 * 
 * @see IWorkbenchWindowActionDelegate#run
 */
public void run(IAction action) {
    NotesThread.sinitThread();
    try {
        final NotesViewData data = getViewData();
        if (data != null) {
            if (Prompt.YesNo(Messages.ExportAction_0, Messages.ExportAction_2) == 1) {
                filename = getFilename();
                if (filename != null) {
                    NotesSessionJob job = new NotesSessionJob(Messages.ExportAction_0) {
                        @SuppressWarnings("unchecked")
                        @Override
                        protected IStatus runInNotesThread(Session session, final IProgressMonitor monitor)
                                throws NotesException {
                            monitor.beginTask(Messages.ExportAction_8 + data.getName() + Messages.ExportAction_9
                                    + filename + "'.", IProgressMonitor.UNKNOWN);//$NON-NLS-1$
                            ExcelWriter writer = new ExcelWriter();
                            View view = ((NotesViewData) data).open(session);
                            // disable auto updating
                            view.setAutoUpdate(false);
                            writer.createSheet(view.getName().replaceAll("\\\\", "-").trim());//$NON-NLS-1$ //$NON-NLS-2$
                            writer.createTableHeader(view);
                            // get a ViewNavigator instance for all the view entries
                            ViewNavigator nav = view.createViewNav();
                            // and set the size of the preloading cache:
                            nav.setBufferMaxEntries(500);
                            ViewEntry entry = nav.getFirst();
                            int row = 0;
                            while (entry != null) {
                                // check that the user does not press "Cancel"
                                if (monitor.isCanceled()) {
                                    monitor.done();
                                    return new Status(IStatus.CANCEL, Activator.PLUGIN_ID,
                                            Messages.ExportAction_4);
                                }
                                if (entry.isValid()) {
                                    if (entry.isDocument()) {
                                        writer.cerateRow(++row, entry.getColumnValues());
                                    }
                                }
                                ViewEntry tmpEntry = nav.getNext();
                                entry.recycle();
                                entry = tmpEntry;
                            }
                            nav.recycle();
                            if (view != null) {
                                view.recycle();
                            }
                            writer.setAutoSizeColumns();
                            monitor.done();
                            try {
                                FileOutputStream fileOut = new FileOutputStream(filename);
                                writer.getWorkbook().write(fileOut);
                                fileOut.close();
                            } catch (FileNotFoundException e) {
                                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
                            } catch (IOException e) {
                                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
                            }
                            return Status.OK_STATUS;
                        }
                    };
                    // Set up the job, then join with it
                    job.setPriority(Job.SHORT);
                    job.setUser(true);
                    job.schedule();
                    // Add ourselves as a listener for when the job ends
                    job.addJobChangeListener(this);
                }
            }
        }
    } catch (final Exception e) {
        log.fatal(e.getMessage(), e);
        error(e);
    } finally {
        NotesThread.stermThread();
    }
}

From source file:com.a544jh.kanamemory.ui.ProfileChooserPanel.java

public void populateList() {
    listmodel = new DefaultListModel<>();
    ArrayList<String> names;
    try {//  ww  w . jav a2  s. c  om
        names = JsonFileReader.ProfilesList("profiles");
    } catch (FileNotFoundException ex) {
        System.out.println("Profiles file not found. A new one will be created.");
        names = new ArrayList<>();
    } catch (JSONException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage() + "\nFix or delete the profiles file.",
                "Profiles file malformed", JOptionPane.ERROR_MESSAGE);
        System.exit(0);
        names = new ArrayList<>();
    }
    for (String string : names) {
        listmodel.addElement(string);
    }
    profilesList.setModel(listmodel);
}

From source file:at.tuwien.minimee.migration.engines.MiniMeeDefaultMigrationEngine.java

/**
 * writes the input bytestream to a file
 * @param data to be migrated//  www . j  av a2 s .c  om
 * @param config {@link ToolConfig} for this migration run
 * @param time the identifier for this migration run
 * @return absolute path of the file that the bytestream has been written to
 * @throws FileNotFoundException if the constructed filename can't be found 
 * @throws IOException if anything else goes wrong with writing the file
 */
protected String prepareInputFile(byte[] data, ToolConfig config, long time) {
    String inputFile = makeInputFilename(config, time);
    OutputStream in;
    try {
        in = new BufferedOutputStream(new FileOutputStream(inputFile));
        in.write(data);
        in.close();
    } catch (FileNotFoundException e) {
        log.error(e.getMessage(), e);
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }

    return inputFile;
}

From source file:edu.nwpu.gemfire.monitor.data.DataBrowser.java

/**
 * generateQueryKey method stores queries in query history file.
 * /* w  ww  . jav  a 2s  . c o  m*/
 * @return Boolean true is operation is successful, false otherwise
 */
private boolean storeQueriesInFile(ObjectNode queries) {
    boolean operationStatus = false;
    FileOutputStream fileOut = null;

    File file = new File(Repository.get().getPulseConfig().getQueryHistoryFileName());
    try {
        fileOut = new FileOutputStream(file);

        // if file does not exists, then create it
        if (!file.exists()) {
            file.createNewFile();
        }

        // get the content in bytes
        byte[] contentInBytes = queries.toString().getBytes();

        fileOut.write(contentInBytes);
        fileOut.flush();

        operationStatus = true;
    } catch (FileNotFoundException e) {

        if (LOGGER.fineEnabled()) {
            LOGGER.fine(resourceBundle.getString("LOG_MSG_DATA_BROWSER_QUERY_HISTORY_FILE_NOT_FOUND") + " : "
                    + e.getMessage());
        }
    } catch (IOException e) {
        if (LOGGER.infoEnabled()) {
            LOGGER.info(e.getMessage());
        }
    } finally {
        if (fileOut != null) {
            try {
                fileOut.close();
            } catch (IOException e) {
                if (LOGGER.infoEnabled()) {
                    LOGGER.info(e.getMessage());
                }
            }
        }
    }
    return operationStatus;
}

From source file:com.mbrlabs.mundus.core.project.ProjectManager.java

/**
 * Loads and opens scene/*w ww.  j av a 2 s. com*/
 *
 * @param projectContext    project context of scene
 * @param sceneName         scene name
 */
public void changeScene(ProjectContext projectContext, String sceneName) {
    try {
        EditorScene newScene = loadScene(projectContext, sceneName);
        projectContext.currScene.dispose();
        projectContext.currScene = newScene;

        Gdx.graphics.setTitle(constructWindowTitle());
        Mundus.postEvent(new SceneChangedEvent());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        Log.error(e.getMessage());
    }
}

From source file:manager.doCreateToy.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.// ww w .j av a2 s .c o m
 *
 * @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");
    PrintWriter out = response.getWriter();
    String categoryList = "";
    String fileName = null;

    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);

            for (FileItem item : multiparts) {
                if (!item.isFormField()) {
                    String name = new File(item.getName()).getName();
                    imageFile = new File(item.getName());

                    fileName = name;
                } else {
                    if (item.getFieldName().equals("toyID")) {
                        toyID = Integer.parseInt(item.getString());
                    }
                    if (item.getFieldName().equals("toyName")) {
                        toyName = item.getString();
                    }
                    if (item.getFieldName().equals("description")) {
                        description = item.getString();
                    }

                    if (item.getFieldName().equals("category")) {
                        categoryList += item.getString();

                    }
                    if (item.getFieldName().equals("secondHand")) {
                        secondHand = item.getString();
                    }

                    if (item.getFieldName().equals("cashpoint")) {
                        cashpoint = Integer.parseInt(item.getString());
                    }
                    if (item.getFieldName().equals("qty")) {
                        qty = Integer.parseInt(item.getString());
                    }
                    if (item.getFieldName().equals("discount")) {
                        discount = Integer.parseInt(item.getString());
                    }

                    if (item.getFieldName().equals("uploadString")) {
                        base64String = item.getString();
                    }
                    //if(item.getFieldName().equals("desc"))
                    // desc= item.getString();
                }
            }
            category = categoryList.split(";");

            //File uploaded successfully
            //request.setAttribute("message", "File Uploaded Successfully" + desc);
        } catch (Exception ex) {

            request.setAttribute("message", "File Upload Failed due to " + ex);
        }

    }
    File file = imageFile;
    if (!(fileName == null)) {

        try {
            /*
            * Reading a Image file from file system
             */
            FileInputStream imageInFile = new FileInputStream(file);
            byte imageData[] = new byte[(int) file.length()];
            imageInFile.read(imageData);

            /*
            * Converting Image byte array into Base64 String 
             */
            String imageDataString = encodeImage(imageData);
            request.setAttribute("test", imageDataString);
            /*
            * Converting a Base64 String into Image byte array 
             */
            //byte[] imageByteArray = decodeImage(imageDataString);

            /*
            * Write a image byte array into file system  
             */
            //FileOutputStream imageOutFile = new FileOutputStream("C:\\Users\\Mesong\\Pictures\\Screenshots\\30.png");
            //imageOutFile.write(imageByteArray);
            //request.setAttribute("photo", imageDataString);
            // toyDB toydb = new toyDB();
            //Toy t = toydb.listToyByID(1);
            // toydb.updateToy(t.getToyID(), imageDataString, t.getCashpoint(), t.getQTY(), t.getDiscount());
            imageInFile.close();
            //request.getRequestDispatcher("managerPage/result.jsp").forward(request, response);
            //imageOutFile.close();

            imgString = imageDataString;
            System.out.println("Image Successfully Manipulated!");
        } catch (FileNotFoundException e) {
            out.println("Image not found" + e.getMessage());
        } catch (IOException ioe) {
            System.out.println("Exception while reading the Image " + ioe);
        }
    }
    try {
        toyDB toydb = new toyDB();
        // out.println("s");

        //           int toyID = Integer.parseInt(request.getParameter("toyID"));
        //           String toyName = request.getParameter("toyName");
        //           String description = request.getParameter("description");
        //          
        //           String toyIcon = request.getParameter("toyIcon");
        //           
        //           String[] category = request.getParameterValues("category");
        //           String secondHand = request.getParameter("secondHand");
        //           if(toyIcon==null) toyIcon = "";
        //           int cashpoint = Integer.parseInt(request.getParameter("cashpoint"));
        //           int qty = Integer.parseInt(request.getParameter("qty"));
        //           int discount = Integer.parseInt(request.getParameter("discount"));
        //toydb.updateToy(toyID, toyName,description, toyIcon, cashpoint, qty, discount);
        if (!base64String.equals(""))
            imgString = base64String;
        toydb.createToy(toyName, description, imgString, cashpoint, qty, discount);
        //for(String c : category)
        //   out.println(c);

        out.println(toyID);
        out.println(description);
        out.println(toyIcon);
        out.println(cashpoint);
        out.println(qty);
        out.println(discount);

        toyCategoryDB toyCatdb = new toyCategoryDB();

        // toyCatdb.deleteToyType(toyID);
        for (String c : category) {
            toyCatdb.createToyCategory(Integer.parseInt(c), toyID);
        }
        if (!secondHand.equals("")) {
            secondHandDB seconddb = new secondHandDB();
            SecondHand sh = seconddb.searchSecondHand(Integer.parseInt(secondHand));
            int secondHandCashpoint = sh.getCashpoint();
            toydb.updateToySecondHand(toyID, Integer.parseInt(secondHand));
            toydb.updateToy(toyID, imgString, secondHandCashpoint, qty, discount);
        } else {
            toydb.updateToySecondHand(toyID, -1);

        }
        //out.println(imgString);
        response.sendRedirect("doSearchToy");

    } catch (Exception e) {
        out.println(e.toString());
    } finally {
        out.close();
    }
}

From source file:com.waveface.installer.util.ImageDownloader.java

/**
 * Adds this bitmap to the cache.//w  w w. jav  a 2  s .com
 * @param bitmap The newly downloaded bitmap.
 */
private void addBitmapToCache(String url, Bitmap bitmap) {
    if (bitmap != null) {
        File cacheDir = mContext.getCacheDir();
        String filename = Base64.encodeToString(url.getBytes(), Base64.DEFAULT);
        synchronized (sHardBitmapCache) {
            sHardBitmapCache.put(url, bitmap);
        }

        File file = new File(cacheDir, filename);
        FileOutputStream out;
        try {
            out = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
        } catch (FileNotFoundException e) {
            Log.d(LOG_TAG, e.getMessage());
        }
    }
}

From source file:com.manning.androidhacks.hack040.util.DiskLruCache.java

/**
 * Add a bitmap to the disk cache.//  ww  w  .j av  a  2s  .  co m
 * 
 * @param key
 *          A unique identifier for the bitmap.
 * @param data
 *          The bitmap to store.
 */
public void put(String key, Bitmap data) {
    synchronized (mLinkedHashMap) {
        if (mLinkedHashMap.get(key) == null) {
            try {
                final String file = createFilePath(mCacheDir, key);
                if (writeBitmapToFile(data, file)) {
                    put(key, file);
                    flushCache();
                }
            } catch (final FileNotFoundException e) {
                Log.e(TAG, "Error in put: " + e.getMessage());
            } catch (final IOException e) {
                Log.e(TAG, "Error in put: " + e.getMessage());
            }
        }
    }
}

From source file:com.cloudapp.rest.CloudApi.java

/**
 * Upload a file to the CloudApp servers.
 * //w w  w .jav a 2 s .  c o m
 * @param file
 *          The file that should be stored.
 * @return A JSONObject with the returned output from the CloudApp servers.
 * @throws CloudApiException
 */
public JSONObject uploadFile(File file) throws CloudApiException {
    try {
        CloudAppInputStream input = new CloudAppInputStream(file);
        return uploadFile(input);
    } catch (FileNotFoundException e) {
        LOGGER.error("The provided file could not be found.", e);
        throw new CloudApiException(500, e.getMessage(), e);
    }
}

From source file:org.dataone.proto.trove.mn.service.v1.impl.MNReadImpl.java

@Override
public InputStream get(Identifier pid)
        throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure, NotFound, InsufficientResources {

    InputStream inputStream = null;
    try {//from   ww w.j  a  v  a 2 s. co m
        ObjectList objectList = new ObjectList();
        inputStream = (InputStream) dataoneDataObjectDirectory.get(pid);

        //            logger.info("get filepath: " + filePath);
        //            inputStream = new FileInputStream(new File(filePath));
        logger.debug("is it available? " + inputStream.available());
    } catch (FileNotFoundException ex) {
        logger.warn(ex);
        NotFound exception = new NotFound("000", ex.getMessage());
        throw exception;
    } catch (IOException ex) {
        logger.warn(ex);
        ServiceFailure exception = new ServiceFailure("001", ex.getMessage());
        throw exception;
    }
    return inputStream;
}