Example usage for java.io FileNotFoundException getClass

List of usage examples for java.io FileNotFoundException getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.runbuddy.tomahawk.dialogs.RemovePluginConfigDialog.java

@Override
protected void onPositiveAction() {
    File destDir = new File(mScriptResolver.getScriptAccount().getPath().replaceFirst("file:", ""));
    try {/* w ww .  j  a  va 2s.com*/
        VariousUtils.deleteRecursive(destDir);
        mScriptResolver.getScriptAccount().unregisterAllPlugins();
    } catch (FileNotFoundException e) {
        Log.d(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
    }
    PipeLine.get().removeResolver(mScriptResolver);
    dismiss();
}

From source file:org.tomahawk.tomahawk_android.dialogs.RemovePluginConfigDialog.java

@Override
protected void onPositiveAction() {
    File destDir = new File(mScriptResolver.getScriptAccount().getPath().replaceFirst("file:", ""));
    try {/*from  ww  w  .  j a v  a  2s . c o  m*/
        VariousUtils.deleteRecursive(destDir);
        mScriptResolver.getScriptAccount().unregisterAllPlugins();
    } catch (FileNotFoundException e) {
        Log.d(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
    }
    dismiss();
}

From source file:org.runbuddy.tomahawk.dialogs.InstallPluginConfigDialog.java

@Override
protected void onPositiveAction() {
    new Thread(new Runnable() {
        @Override//from w w w  .j  a v a2s .  c  o  m
        public void run() {
            String destDirPath = TomahawkApp.getContext().getFilesDir().getAbsolutePath() + File.separator
                    + "manualresolvers" + File.separator + ".temp";
            File destDir = new File(destDirPath);
            try {
                VariousUtils.deleteRecursive(destDir);
            } catch (FileNotFoundException e) {
                Log.d(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            try {
                if (UnzipUtils.unzip(mPathToAxe, destDirPath)) {
                    File metadataFile = new File(
                            destDirPath + File.separator + "content" + File.separator + "metadata.json");
                    String metadataString = FileUtils.readFileToString(metadataFile, Charsets.UTF_8);
                    ScriptResolverMetaData metaData = GsonHelper.get().fromJson(metadataString,
                            ScriptResolverMetaData.class);
                    final File renamedFile = new File(destDir.getParent() + File.separator + metaData.pluginName
                            + "_" + System.currentTimeMillis());
                    boolean success = destDir.renameTo(renamedFile);
                    if (!success) {
                        Log.e(TAG, "onPositiveAction - Wasn't able to rename directory: "
                                + renamedFile.getAbsolutePath());
                    }
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            PipeLine.get().addScriptAccount(new ScriptAccount(renamedFile.getPath(), true));
                        }
                    });
                }
            } catch (IOException e) {
                Log.e(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
    }).start();
    dismiss();
}

From source file:org.tomahawk.tomahawk_android.dialogs.InstallPluginConfigDialog.java

@Override
protected void onPositiveAction() {
    new Thread(new Runnable() {
        @Override//from  ww  w  . j  a v a 2s . com
        public void run() {
            String destDirPath = TomahawkApp.getContext().getFilesDir().getAbsolutePath() + File.separator
                    + "manualresolvers" + File.separator + ".temp";
            File destDir = new File(destDirPath);
            try {
                VariousUtils.deleteRecursive(destDir);
            } catch (FileNotFoundException e) {
                Log.d(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
            try {
                if (UnzipUtility.unzip(mPathToAxe, destDirPath)) {
                    File metadataFile = new File(
                            destDirPath + File.separator + "content" + File.separator + "metadata.json");
                    String metadataString = FileUtils.readFileToString(metadataFile, Charsets.UTF_8);
                    ScriptResolverMetaData metaData = GsonHelper.get().fromJson(metadataString,
                            ScriptResolverMetaData.class);
                    final File renamedFile = new File(destDir.getParent() + File.separator + metaData.pluginName
                            + "_" + System.currentTimeMillis());
                    destDir.renameTo(renamedFile);
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            PipeLine.get().addScriptAccount(new ScriptAccount(renamedFile.getPath(), true));
                        }
                    });
                }
            } catch (IOException e) {
                Log.e(TAG, "onPositiveAction: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
    }).start();
    dismiss();
}

From source file:com.qumasoft.guitools.compare.FileContentsListModel.java

FileContentsListModel(File file, CompareFilesForGUI compareResult, boolean isFirstFile,
        FileContentsListModel firstFileListModel) {
    super();/*from   www .ja va  2  s  .com*/
    this.currentDifferenceIndex = -1;
    BufferedReader fileReader = null;
    if (file.canRead()) {
        try {
            fileReader = new BufferedReader(new FileReader(file));
            int lineIndex = 0;
            while (true) {
                String line = fileReader.readLine();
                if (line == null) {
                    break;
                }
                String formattedLine = formatLine(line);
                ContentRow row = new ContentRow(formattedLine, line, compareResult, lineIndex, isFirstFile);
                if (!isFirstFile) {
                    // If this is the 2nd file, for replacement lines figure out where in the line things are different.
                    if (row.getRowType() == ContentRow.ROWTYPE_REPLACE) {
                        System.out.println("lineIndex: [" + lineIndex + "]");
                        ContentRow firstModelRow = firstFileListModel.get(lineIndex);
                        row.decorateDifferences(firstModelRow);
                        firstModelRow.decorateDifferences(row);
                    }
                }
                if (row.getBlankRowsBefore() > 0) {
                    for (int i = 0; i < row.getBlankRowsBefore(); i++) {
                        addBlankRow(row.getDelta());
                    }
                }
                addElement(row);
                if (row.getBlankRowsAfter() > 0) {
                    for (int i = 0; i < row.getBlankRowsAfter(); i++) {
                        addBlankRow(row.getDelta());
                    }
                }
                lineIndex++;
            }
        } catch (java.io.FileNotFoundException e) {
            LOGGER.log(Level.WARNING,
                    "Caught exception: " + e.getClass().toString() + ": " + e.getLocalizedMessage());
        } catch (java.io.IOException e) {
            LOGGER.log(Level.WARNING,
                    "Caught exception: " + e.getClass().toString() + ": " + e.getLocalizedMessage());
        } finally {
            try {
                if (fileReader != null) {
                    fileReader.close();
                }
            } catch (IOException e) {
                LOGGER.log(Level.WARNING,
                        "Caught exception: " + e.getClass().toString() + ": " + e.getLocalizedMessage());
            }
        }
    }
}

From source file:org.exoplatform.utils.ExoDocumentUtils.java

/**
 * Gets a DocumentInfo with info coming from the document at the given URI.
 * /*from   w  ww .  j av  a 2 s.co  m*/
 * @param contentUri the content URI of the document (content:// ...)
 * @param context
 * @return a DocumentInfo or null if an error occurs
 */
public static DocumentInfo documentFromContentUri(Uri contentUri, Context context) {
    if (contentUri == null)
        return null;

    try {
        ContentResolver cr = context.getContentResolver();
        Cursor c = cr.query(contentUri, null, null, null, null);
        int sizeIndex = c.getColumnIndex(OpenableColumns.SIZE);
        int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
        int orientIndex = c.getColumnIndex(MediaStore.Images.ImageColumns.ORIENTATION);
        c.moveToFirst();

        DocumentInfo document = new DocumentInfo();
        document.documentName = c.getString(nameIndex);
        document.documentSizeKb = c.getLong(sizeIndex) / 1024;
        document.documentData = cr.openInputStream(contentUri);
        document.documentMimeType = cr.getType(contentUri);
        if (orientIndex != -1) { // if found orientation column
            document.orientationAngle = c.getInt(orientIndex);
        }
        return document;
    } catch (FileNotFoundException e) {
        Log.d(LOG_TAG, e.getClass().getSimpleName(), e.getLocalizedMessage());
    } catch (Exception e) {
        Log.e(LOG_TAG, "Cannot retrieve the content at " + contentUri);
        if (Log.LOGD)
            Log.d(LOG_TAG, e.getMessage() + "\n" + Log.getStackTraceString(e));
    }
    return null;
}

From source file:de.kaiserpfalzEdv.maven.apacheds.config.LdifLoader.java

private void loadLdifFile(final File ldif) throws MojoExecutionException {
    logger.debug("Loading LDIF: " + ldif);

    try {//from www.j  a v a  2  s.  c o m
        LdifReader ldifReader = new LdifReader();

        for (LdifEntry entry : ldifReader.parseLdif(new BufferedReader(new FileReader(ldif)))) {
            addLdifEntry(entry);
        }
    } catch (FileNotFoundException e) {
        logger.error("File '" + ldif + "' not found. LDIF will not be loaded!");

        throw new MojoExecutionException("Can't load configured LDIF '" + ldif + "'. Tests will fail!", e);
    } catch (Exception e) {
        logger.error(e.getClass().getSimpleName() + " caught: " + e.getMessage(), e);
    }
}

From source file:de.zweipunktfuenf.crypdroid.activities.ActionChooserActivity.java

@Deprecated
private byte[] readDataFile() {
    FileInputStream fis = null;//from   w ww.j  a  v  a  2  s  .  c  o  m
    try {
        fis = openFileInput(CrypdroidActivity.FILE_TEMP_OUT);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        int size;
        byte[] buffer = new byte[4096];
        while (-1 != (size = fis.read(buffer)))
            baos.write(buffer, 0, size);

        baos.flush();
        return baos.toByteArray();

    } catch (FileNotFoundException e) {
        Toast.makeText(this, R.string.error_internal, Toast.LENGTH_LONG).show();
        Log.e("ActionChooserActivity#readDataFile", "" + e.getClass(), e);
        return null;
    } catch (IOException e) {
        Toast.makeText(this, R.string.error_internal, Toast.LENGTH_LONG).show();
        Log.e("ActionChooserActivity#readDataFile", "" + e.getClass(), e);
        return null;
    } finally {
        if (null != fis)
            try {
                fis.close();
            } catch (IOException e) {
                Log.d("ActionChooserActivity#readDataFile", "error while closing internal_out", e);
            }
    }
}

From source file:org.eclipse.mylyn.internal.monitor.usage.UsageUploadManager.java

public IStatus uploadFile(final String postUrl, final String name, final File file, final String filename,
        final int uid, IProgressMonitor monitor) {

    PostMethod filePost = new PostMethod(postUrl);

    try {/*  w  ww . jav a  2 s.  c  o m*/
        Part[] parts = { new FilePart(name, filename, file) };
        filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));

        AbstractWebLocation location = new WebLocation(postUrl);
        HostConfiguration hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor);
        final int status = WebUtil.execute(httpClient, hostConfiguration, filePost, monitor);

        if (status == HttpStatus.SC_UNAUTHORIZED) {
            // The uid was incorrect so inform the user
            return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN, status,
                    NLS.bind(Messages.UsageUploadManager_Error_Uploading_Uid_Incorrect, file.getName(), uid),
                    new Exception());

        } else if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
            return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN, status,
                    Messages.UsageUploadManager_Error_Uploading_Proxy_Authentication, new Exception());
        } else if (status != 200) {
            // there was a problem with the file upload so throw up an error
            // dialog to inform the user
            return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN, status,
                    NLS.bind(Messages.UsageUploadManager_Error_Uploading_Http_Response, file.getName(), status),
                    new Exception());
        } else {
            // the file was uploaded successfully
            return Status.OK_STATUS;
        }

    } catch (final FileNotFoundException e) {
        return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
                NLS.bind(Messages.UsageUploadManager_Error_Uploading_X_Y, file.getName(),
                        e.getClass().getCanonicalName()),
                e);

    } catch (final IOException e) {
        if (e instanceof NoRouteToHostException || e instanceof UnknownHostException) {
            return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
                    NLS.bind(Messages.UsageUploadManager_Error_Uploading_X_No_Network, file.getName()), e);

        } else {
            return new Status(IStatus.ERROR, UiUsageMonitorPlugin.ID_PLUGIN,
                    NLS.bind(Messages.UsageUploadManager_Error_Uploading_X_Y, file.getName(),
                            e.getClass().getCanonicalName()),
                    e);
        }
    } finally {
        filePost.releaseConnection();
    }
}

From source file:org.tomahawk.libtomahawk.resolver.PipeLine.java

private PipeLine() {
    try {// ww  w .  j a v  a 2  s  .  c  om
        String[] plugins = TomahawkApp.getContext().getAssets().list("js/resolvers");
        for (String plugin : plugins) {
            String path = "js/resolvers/" + plugin + "/content";
            try {
                String rawJsonString = TomahawkUtils.inputStreamToString(
                        TomahawkApp.getContext().getAssets().open(path + "/metadata.json"));
                ScriptResolverMetaData metaData = InfoSystemUtils.getObjectMapper().readValue(rawJsonString,
                        ScriptResolverMetaData.class);
                ScriptResolver scriptResolver = new ScriptResolver(metaData, path, this);
                mResolvers.add(scriptResolver);
            } catch (FileNotFoundException e) {
                Log.e(TAG, "PipeLine: " + e.getClass() + ": " + e.getLocalizedMessage());
            } catch (JsonMappingException e) {
                Log.e(TAG, "PipeLine: " + e.getClass() + ": " + e.getLocalizedMessage());
            } catch (JsonParseException e) {
                Log.e(TAG, "PipeLine: " + e.getClass() + ": " + e.getLocalizedMessage());
            } catch (IOException e) {
                Log.e(TAG, "PipeLine: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
    } catch (IOException e) {
        Log.e(TAG, "ensureInit: " + e.getClass() + ": " + e.getLocalizedMessage());
    }
    mResolvers.add(new DataBaseResolver(
            TomahawkApp.getContext().getString(R.string.local_collection_pretty_name), this));
    SpotifyResolver spotifyResolver = new SpotifyResolver(this);
    mResolvers.add(spotifyResolver);
    setAllResolversAdded(true);
}