Example usage for java.io FileNotFoundException toString

List of usage examples for java.io FileNotFoundException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.hurence.logisland.service.cache.CSVKeyValueCacheService.java

private InputStream initFromPath(ControllerServiceInitializationContext context, String dbPath) {
    final File dbFile = new File(dbPath);
    try {//w w w .j  a va 2  s.  com
        return new FileInputStream(dbFile);
    } catch (FileNotFoundException e) {
        logger.info(e.toString());
        return null;
    }

}

From source file:org.apache.nutch.keymatch.SimpleKeyMatcher.java

/**
 * Saves keymatch configuration into file.
 * //from   w  w  w.j a  va2s. c o  m
 * @throws IOException
 */
public void save() throws IOException {
    try {
        final URL url = getConf().getResource(configName);
        if (url == null) {
            throw new IOException("Resource not found: " + configName);
        }
        final FileOutputStream fos = new FileOutputStream(new File(url.getFile()));
        final DocumentImpl doc = new DocumentImpl();
        final Element keymatches = doc.createElement(TAG_KEYMATCHES);
        final Iterator iterator = matches.values().iterator();

        while (iterator.hasNext()) {
            final Element keymatch = doc.createElement(TAG_KEYMATCH);
            final KeyMatch keyMatch = (KeyMatch) iterator.next();
            keyMatch.populateElement(keymatch);
            keymatches.appendChild(keymatch);
        }

        DomUtil.saveDom(fos, keymatches);
        fos.flush();
        fos.close();
    } catch (FileNotFoundException e) {
        throw new IOException(e.toString());
    }
}

From source file:org.kuali.kfs.module.tem.batch.TemProfileExportStep.java

@Override
public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
    List<TemProfile> profiles = temProfileService.getAllActiveTemProfile();

    //Accessing EXPORT_FILE_FORMAT sys param for export file extension
    LOG.info("Accessing EXPORT_FILE_FORMAT system parameter for file extension");
    String extension = getParameterService().getParameterValueAsString(TemProfileExportStep.class,
            TemConstants.TemProfileParameters.EXPORT_FILE_FORMAT);

    //Creating export file name
    String exportFile = fileDirectoryName + File.separator + fileName + "." + extension;

    //Initializing the output stream
    PrintStream OUTPUT_GLE_FILE_ps = null;
    try {/*from w w w  .j av a  2s.c  o  m*/
        OUTPUT_GLE_FILE_ps = new PrintStream(exportFile);
    } catch (FileNotFoundException ex) {
        throw new RuntimeException(ex.toString(), ex);
    }

    //Create file based on extension
    if (extension.equalsIgnoreCase("xml")) {
        try {
            OUTPUT_GLE_FILE_ps.printf("%s\n", generateXMLDoc(profiles));
        } catch (ParserConfigurationException ex) {
            throw new RuntimeException(ex.toString(), ex);
        } catch (TransformerException ex) {
            throw new RuntimeException(ex.toString(), ex);
        }
    } else {
        OUTPUT_GLE_FILE_ps.printf("%s\n",
                getDateTimeService().toDateTimeString(getDateTimeService().getCurrentDate()) + ","
                        + getParameterService().getParameterValueAsString(
                                KfsParameterConstants.FINANCIAL_SYSTEM_ALL.class,
                                KfsParameterConstants.INSTITUTION_NAME));
        for (TemProfile profile : profiles) {
            try {
                OUTPUT_GLE_FILE_ps.printf("%s\n", generateCSVEntry(profile));
            } catch (Exception e) {
                throw new RuntimeException(e.toString(), e);
            }
        }
    }

    OUTPUT_GLE_FILE_ps.close();

    return false;
}

From source file:org.onebusaway.admin.util.NYCFileUtils.java

public InputStream read(String filename) {
    File file = new File(filename);
    if (file.exists()) {
        try {/*  w ww  . ja  v a  2  s.  c  o  m*/
            return new FileInputStream(file);
        } catch (FileNotFoundException e) {
            _log.error(e.toString(), e);
            throw new RuntimeException(e);
        }
    } else {
        _log.info("file not found for read(" + filename + ")");
    }
    return null;
}

From source file:stargate.drivers.userinterface.http.HTTPUserInterfaceServlet.java

@GET
@Path(HTTPUserInterfaceRestfulConstants.RESTFUL_METADATA_PATH)
@Produces(MediaType.APPLICATION_JSON)//from  w w  w  .  ja v a  2  s  . c o  m
public Response getDataObjectMetadataRestful(@DefaultValue("") @QueryParam("path") String path) {
    try {
        RestfulResponse<DataObjectMetadata> rres = new RestfulResponse<DataObjectMetadata>(
                getDataObjectMetadata(path));
        return Response.status(Response.Status.OK).entity(rres).build();
    } catch (FileNotFoundException ex) {
        return Response.status(Response.Status.NOT_FOUND).entity(ex.toString()).build();
    } catch (Exception ex) {
        RestfulResponse<DataObjectMetadata> rres = new RestfulResponse<DataObjectMetadata>(ex);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(rres).build();
    }
}

From source file:com.example.mediasync3.DownloadNote.java

private String readFromFile(String FILENAME) {

    String ret = "";

    try {//from www  .ja  v a 2 s.com
        //InputStream inputStream = mFrag.getActivity().openFileInput(FILENAME);
        //InputStream inputStream = mFrag.getActivity()

        FileInputStream fIn = new FileInputStream(FILENAME);

        if (fIn != null) {

            //if ( inputStream != null ) {
            //InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            //BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fIn));

            String receiveString = "";
            StringBuilder stringBuilder = new StringBuilder();

            while ((receiveString = bufferedReader.readLine()) != null) {
                stringBuilder.append(receiveString);
            }

            fIn.close();
            //inputStream.close();
            ret = stringBuilder.toString();
        }
    } catch (FileNotFoundException e) {
        Log.e(TAG, "File not found: " + e.toString());
    } catch (IOException e) {
        Log.e(TAG, "Can not read file: " + e.toString());
    }

    return ret;
}

From source file:org.transdroid.daemon.BuffaloNas.BuffaloNasAdapter.java

private boolean makeUploadRequest(Log log, String path, String file) throws DaemonException {

    try {//from  w ww .  j  a  v a2s.c o m

        // Initialise the HTTP client
        if (httpclient == null) {
            initialise();
        }

        // Setup request using POST
        HttpPost httppost = new HttpPost(buildWebUIUrl(path));
        File upload = new File(URI.create(file));
        Part[] parts = { new FilePart("fileEl", upload) };
        httppost.setEntity(new MultipartEntity(parts, httppost.getParams()));

        // Make the request
        HttpResponse response = httpclient.execute(httppost);
        return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;

    } catch (FileNotFoundException e) {
        throw new DaemonException(ExceptionType.FileAccessError, e.toString());
    } catch (Exception e) {
        log.d(LOG_NAME, "Error: " + e.toString());
        throw new DaemonException(ExceptionType.ConnectionError, e.toString());
    }

}

From source file:test.TestInputFiles.java

public String[] readFromInternalAutoForward(String rootFolder) {
    Integer index = 1;/*from w  w  w .  jav  a  2 s  . c o m*/
    BufferedReader fileReader = null;
    String fileToParseNew = rootFolder + 1 + ".json";
    try {
        String line = "";
        //Read the file line by line
        int i = 1;
        while (i <= index) {
            String output = "";
            fileToParseNew = rootFolder + i + ".json";
            try {
                fileReader = new BufferedReader(new FileReader(fileToParseNew));
            } catch (FileNotFoundException ex) {
                loggerObj.log(Level.INFO, "Error in reading MEMDM server files from internal file"
                        + fileToParseNew + "Exception is: " + ex.toString());
            }
            while ((line = fileReader.readLine()) != null) {
                output += line;
            }
            JSONParser parser = new JSONParser();
            try {
                JSONObject json = (JSONObject) parser.parse(output);
            } catch (ParseException ex) {
                loggerObj.log(Level.INFO,
                        "Error in parsing MEMDM server files from internal file" + fileToParseNew);
            }
            i++;
        }
    } catch (IOException ex) {
        loggerObj.log(Level.INFO, "Error in reading MEMDM server files from internal files" + fileToParseNew);
        return null;
    } finally {
        try {
            fileReader.close();
        } catch (IOException ex) {
            loggerObj.log(Level.INFO,
                    "Error in closing the fileReader while closing the file" + fileToParseNew);
        }
    }
    return new String[] { rootFolder, index.toString() };
}

From source file:edu.stanford.mobisocial.dungbeetle.ImageViewerActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case SAVE: {// w ww  . j  a  v a 2  s.  c  om
        OutputStream outStream = null;
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
        Date date = new Date();
        File file = new File(extStorageDirectory, dateFormat.format(date) + ".PNG");
        File fileDirectory = new File(extStorageDirectory);
        fileDirectory.mkdirs();
        try {
            outStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
            outStream.flush();
            outStream.close();

            Toast.makeText(ImageViewerActivity.this, "Saved", Toast.LENGTH_LONG).show();

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Toast.makeText(ImageViewerActivity.this, e.toString(), Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Toast.makeText(ImageViewerActivity.this, e.toString(), Toast.LENGTH_LONG).show();
        }
        return true;
    }
    case SET_PROFILE: {
        if (mIntent.hasExtra("b64Bytes")) {
            String b64Bytes = mIntent.getStringExtra("b64Bytes");
            byte[] data = FastBase64.decode(b64Bytes);
            Helpers.updatePicture(ImageViewerActivity.this, data);
            Toast.makeText(ImageViewerActivity.this, "Set profile picture.", Toast.LENGTH_LONG).show();

        } else {
            Toast.makeText(ImageViewerActivity.this, "Error setting profile picture.", Toast.LENGTH_LONG)
                    .show();
        }
        return true;
    }
    default:
        return false;
    }
}

From source file:test.TestInputFiles.java

private String[] InternalFilesForSupToRepSync() {
    Integer index = 104;//from www  .ja va2  s  .  c  om
    BufferedReader fileReader = null;
    String fileToParse = "./Files/TestFiles/SupToRepSync/MEDCServer/DC/JSONResponse_";
    String fileToParseNew = fileToParse + 1 + ".json";
    try {
        String line = "";
        //Read the file line by line
        int i = 1;
        JSONArray test = new JSONArray();
        while (i <= index) {
            String output = "";
            fileToParseNew = fileToParse + i + ".json";
            try {
                fileReader = new BufferedReader(new FileReader(fileToParseNew));
            } catch (FileNotFoundException ex) {
                loggerObj.log(Level.INFO, "Error in reading MEMDM server files from internal file"
                        + fileToParseNew + "Exception is: " + ex.toString());
            }
            while ((line = fileReader.readLine()) != null) {
                output += line;
            }
            JSONParser parser = new JSONParser();
            try {
                JSONObject json = (JSONObject) parser.parse(output);
                test.add(json);
            } catch (ParseException ex) {
                loggerObj.log(Level.INFO,
                        "Error in parsing MEMDM server files from internal file" + fileToParseNew);
            }
            i++;
        }
    } catch (IOException ex) {
        loggerObj.log(Level.INFO, "Error in reading MEMDM server files from internal files" + fileToParseNew);
        return null;
    } finally {
        try {
            fileReader.close();
        } catch (IOException ex) {
            loggerObj.log(Level.INFO,
                    "Error in closing the fileReader while closing the file" + fileToParseNew);
        }
    }
    return new String[] { fileToParse, index.toString() };
}