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.vkassin.mtrade.Common.java

public static void saveArcDeals() {

    Log.i(TAG, "saveArcDeals()");
    FileOutputStream fos;//  w w  w  .j  a v a  2s  . co  m
    try {

        fos = app_ctx.openFileOutput(ARCDEAL_FNAME, Context.MODE_PRIVATE);
        ObjectOutputStream os = new ObjectOutputStream(fos);
        os.writeObject(arcdealMap);
        os.close();
        fos.close();

    } catch (FileNotFoundException e) {

        Toast.makeText(app_ctx, "  ?  ? " + e.toString(),
                Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } catch (IOException e) {

        Toast.makeText(app_ctx, "  ?  ?: " + e.toString(),
                Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }

}

From source file:com.ddoskify.CameraOverlayActivity.java

/**
 * Initializes the UI and initiates the creation of a face detector.
 *///  www .  ja va 2s .c  o m
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    FacebookSdk.sdkInitialize(getApplicationContext());
    AppEventsLogger.activateApp(this);

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);
    mFaces = new ArrayList<FaceTracker>();

    final ImageButton button = (ImageButton) findViewById(R.id.flipButton);
    button.setOnClickListener(mFlipButtonListener);

    if (savedInstanceState != null) {
        mIsFrontFacing = savedInstanceState.getBoolean("IsFrontFacing");
    }

    mTakePictureButton = (Button) findViewById(R.id.takePictureButton);
    mTakePictureButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.e("CameraOverlay", "Button has been pressed");
            mCameraSource.takePicture(new CameraSource.ShutterCallback() {
                @Override
                public void onShutter() {
                    //                        mCameraSource.stop();
                    Snackbar.make(findViewById(android.R.id.content), "Picture Taken!", Snackbar.LENGTH_SHORT)
                            .setActionTextColor(Color.BLACK).show();
                }
            }, new CameraSource.PictureCallback() {
                public void onPictureTaken(byte[] data) {
                    int re = ActivityCompat.checkSelfPermission(getApplicationContext(),
                            Manifest.permission.WRITE_EXTERNAL_STORAGE);

                    if (!isStorageAllowed()) {
                        requestStoragePermission();
                    }

                    File pictureFile = getOutputMediaFile();
                    if (pictureFile == null) {
                        return;
                    }
                    try {

                        Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length);
                        Bitmap resizedBitmap = Bitmap.createBitmap(mGraphicOverlay.getWidth(),
                                mGraphicOverlay.getHeight(), picture.getConfig());
                        Canvas canvas = new Canvas(resizedBitmap);

                        Matrix matrix = new Matrix();

                        matrix.setScale((float) resizedBitmap.getWidth() / (float) picture.getWidth(),
                                (float) resizedBitmap.getHeight() / (float) picture.getHeight());

                        if (mIsFrontFacing) {
                            // mirror by inverting scale and translating
                            matrix.preScale(-1, 1);
                            matrix.postTranslate(canvas.getWidth(), 0);
                        }
                        Paint paint = new Paint();
                        canvas.drawBitmap(picture, matrix, paint);

                        mGraphicOverlay.draw(canvas); // make those accessible

                        FileOutputStream fos = new FileOutputStream(pictureFile);
                        resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 80, fos);
                        fos.close();

                        Intent intent = new Intent(getApplicationContext(), PhotoReviewActivity.class);
                        intent.putExtra(BITMAP_MESSAGE, pictureFile.toString());
                        startActivity(intent);
                        Log.d("CameraOverlay", "Starting PhotoReviewActivity " + pictureFile.toString());

                    } catch (FileNotFoundException e) {
                        Log.e("CameraOverlay", e.toString());
                    } catch (IOException e) {
                        Log.e("CameraOverlay", e.toString());
                    }
                }
            });
        }
    });

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource();
    } else {
        requestCameraPermission();
    }
}

From source file:com.cisco.oss.foundation.logging.FoundationLogger.java

private static Properties getLogProperties(final URL logPropFileResource) {

    final Properties properties = new Properties();
    InputStream propertiesInStream = null;
    final String log4jFilePath = logPropFileResource.getPath();
    try {/*w  w w  .j ava  2  s  . com*/
        propertiesInStream = logPropFileResource.openStream();
        properties.load(propertiesInStream);
    } catch (FileNotFoundException e) {
        System.err.println("[FoundationLogger] Can not find the file: " + log4jFilePath); // NOPMD
        throw new FoundationIOException("Can not find the file: " + log4jFilePath, e);
    } catch (IOException e) {
        System.err.println("[FoundationLogger] IO Exception during load of file: " + log4jFilePath
                + ". Exception is: " + e.toString()); // NOPMD
        throw new FoundationIOException(
                "IO Exception during load of file: " + log4jFilePath + ". Exception is: " + e.toString(), e);
    } finally {
        if (propertiesInStream != null) {
            try {
                propertiesInStream.close();
            } catch (IOException e) {
                System.err.println("[FoundationLogger] IO Exception during close of file: " + log4jFilePath
                        + ". Exception is: " + e.toString()); // NOPMD
            }
        }
    }
    return properties;
}

From source file:org.apache.hadoop.hive.ql.exec.ACLTask.java

private int showGrants(Hive db, showGrantsDesc showGrantsD) throws HiveException {
    List<String> grants = db.showGrants(showGrantsD.getWho(), showGrantsD.getUser());

    try {/*from  w  w  w .ja  v a  2s  .  c  o  m*/
        FileSystem fs = showGrantsD.getTmpFile().getFileSystem(conf);
        DataOutput outStream = (DataOutput) fs.create(showGrantsD.getTmpFile());
        Iterator<String> iterGrants = grants.iterator();

        while (iterGrants.hasNext()) {
            outStream.writeBytes(iterGrants.next());
            outStream.write(terminator);
        }
        ((FSDataOutputStream) outStream).close();
    } catch (FileNotFoundException e) {
        LOG.warn("show grants: " + StringUtils.stringifyException(e));
        return 1;
    } catch (IOException e) {
        LOG.warn("show grants: " + StringUtils.stringifyException(e));
        return 1;
    } catch (Exception e) {
        throw new HiveException(e.toString());
    }
    return 0;
}

From source file:org.apache.hadoop.hive.ql.exec.ACLTask.java

private int showUsers(Hive db, showUsersDesc showUsersD) throws HiveException {
    List<String> users = db.showUsers(showUsersD.getWho());

    try {// w  w  w . java2  s .co m
        FileSystem fs = showUsersD.getTmpFile().getFileSystem(conf);
        DataOutput outStream = (DataOutput) fs.create(showUsersD.getTmpFile());
        SortedSet<String> sortedUsers = new TreeSet<String>(users);
        Iterator<String> iterUsers = sortedUsers.iterator();

        outStream.writeBytes("All users in TDW:");
        outStream.write(terminator);

        while (iterUsers.hasNext()) {
            outStream.writeBytes(iterUsers.next());
            outStream.write(terminator);
        }
        ((FSDataOutputStream) outStream).close();
    } catch (FileNotFoundException e) {
        LOG.warn("show users: " + StringUtils.stringifyException(e));
        return 1;
    } catch (IOException e) {
        LOG.warn("show users: " + StringUtils.stringifyException(e));
        return 1;
    } catch (Exception e) {
        throw new HiveException(e.toString());
    }
    LOG.info("show users OK");
    return 0;
}

From source file:org.apache.hadoop.hive.ql.exec.ACLTask.java

private int showRoles(Hive db, showRolesDesc showRolesD) throws HiveException {

    List<String> roles;
    if (showRolesD.getUser() == null)
        roles = db.showRoles(showRolesD.getWho());
    else//from  w  w w .  j  ava2 s.com
        return 0;

    try {
        FileSystem fs = showRolesD.getTmpFile().getFileSystem(conf);
        DataOutput outStream = (DataOutput) fs.create(showRolesD.getTmpFile());
        LOG.info("show roles tmp file:" + showRolesD.getTmpFile().toString());
        SortedSet<String> sortedRoles = new TreeSet<String>(roles);
        Iterator<String> iterRoles = sortedRoles.iterator();

        outStream.writeBytes("ALL roles in TDW:");
        outStream.write(terminator);

        while (iterRoles.hasNext()) {
            outStream.writeBytes(iterRoles.next());
            outStream.write(terminator);
        }
        ((FSDataOutputStream) outStream).close();
    } catch (FileNotFoundException e) {
        LOG.warn("show roles: " + StringUtils.stringifyException(e));
        return 1;
    } catch (IOException e) {
        LOG.warn("show roles: " + StringUtils.stringifyException(e));
        return 1;
    } catch (Exception e) {
        throw new HiveException(e.toString());
    }
    LOG.info("show roles OK");
    return 0;
}

From source file:com.polyvi.xface.extension.filetransfer.XFileTransferExt.java

/**
 * ????XFileUploadResult//from w ww . j a v  a2  s .  com
 * @param result        js
 * @param conn          Http
 */
private void setUploadResult(XFileUploadResult result, HttpURLConnection conn) {
    StringBuffer responseString = new StringBuffer("");
    DataInputStream inStream = null;
    try {
        inStream = new DataInputStream(conn.getInputStream());
        String line = null;
        while ((line = inStream.readLine()) != null) {
            responseString.append(line);
        }

        // XFileUploadResult?
        result.setResponseCode(conn.getResponseCode());
        result.setResponse(responseString.toString());
        inStream.close();
    } catch (FileNotFoundException e) {
        XLog.e(CLASS_NAME, e.toString());
    } catch (IOException e) {
        XLog.e(CLASS_NAME, e.toString());
    }
}

From source file:org.cerberus.engine.execution.impl.RecorderService.java

@Override
public TestCaseExecutionFile recordPageSource(TestCaseExecution testCaseExecution,
        TestCaseStepActionExecution testCaseStepActionExecution, Integer control) {
    // Used for logging purposes
    String logPrefix = Infos.getInstance().getProjectNameAndVersion() + " - ";

    LOG.debug(logPrefix + "Starting to save Page Source File.");

    TestCaseExecutionFile object = null;
    String test = testCaseExecution.getTest();
    String testCase = testCaseExecution.getTestCase();
    String step = String.valueOf(testCaseStepActionExecution.getStep());
    String index = String.valueOf(testCaseStepActionExecution.getIndex());
    String sequence = String.valueOf(testCaseStepActionExecution.getSequence());
    String controlString = control.equals(0) ? null : String.valueOf(control);

    try {//from www. j ava 2s  .  co  m
        Recorder recorder = this.initFilenames(
                testCaseStepActionExecution.getTestCaseStepExecution().gettCExecution().getId(), test, testCase,
                step, index, sequence, controlString, null, 0, "pagesource", "html");
        File dir = new File(recorder.getFullPath());
        dir.mkdirs();

        File file = new File(recorder.getFullFilename());

        FileOutputStream fileOutputStream;
        try {
            fileOutputStream = new FileOutputStream(file);
            fileOutputStream
                    .write(this.webdriverService.getPageSource(testCaseExecution.getSession()).getBytes());
            fileOutputStream.close();

            // Index file created to database.
            object = testCaseExecutionFileFactory.create(0, testCaseExecution.getId(), recorder.getLevel(),
                    "Page Source", recorder.getRelativeFilenameURL(), "HTML", "", null, "", null);
            testCaseExecutionFileService.save(object);

        } catch (FileNotFoundException ex) {
            LOG.error(logPrefix + ex.toString());

        } catch (IOException ex) {
            LOG.error(logPrefix + ex.toString());
        }

        LOG.debug(logPrefix + "Page Source file saved in : " + recorder.getRelativeFilenameURL());
    } catch (CerberusException ex) {
        LOG.error(logPrefix + ex.toString());
    }
    return object;
}

From source file:com.qut.middleware.crypto.impl.CryptoProcessorImpl.java

public void serializeKeyStore(KeyStore keyStore, String keyStorePassphrase, String filename)
        throws CryptoException {
    FileOutputStream fos = null;//from  w w w. j  a  v a 2 s . c o  m
    try {
        fos = new FileOutputStream(filename);
        keyStore.store(fos, keyStorePassphrase.toCharArray());
    } catch (FileNotFoundException e) {
        this.logger.error(e.getLocalizedMessage());
        this.logger.debug(e.toString());
        throw new CryptoException(e.getLocalizedMessage(), e);
    } catch (KeyStoreException e) {
        this.logger.error(e.getLocalizedMessage());
        this.logger.debug(e.toString());
        throw new CryptoException(e.getLocalizedMessage(), e);
    } catch (NoSuchAlgorithmException e) {
        this.logger.error(e.getLocalizedMessage());
        this.logger.debug(e.toString());
        throw new CryptoException(e.getLocalizedMessage(), e);
    } catch (CertificateException e) {
        this.logger.error(e.getLocalizedMessage());
        this.logger.debug(e.toString());
        throw new CryptoException(e.getLocalizedMessage(), e);
    } catch (IOException e) {
        this.logger.error(e.getLocalizedMessage());
        this.logger.debug(e.toString());
        throw new CryptoException(e.getLocalizedMessage(), e);
    } finally {
        if (fos != null) {
            try {
                fos.flush();
                fos.close();
            } catch (IOException e) {
                this.logger.error(e.getLocalizedMessage());
                this.logger.debug(e.toString());
                throw new CryptoException(e.getLocalizedMessage(), e);
            }
        }
    }
}