Search in sources :

Example 91 with FileNotFoundException

use of java.io.FileNotFoundException in project platform_frameworks_base by android.

the class FontFamily_Delegate method setFontLocation.

public static synchronized void setFontLocation(String fontLocation) {
    sFontLocation = fontLocation;
    // init list of bundled fonts.
    File allFonts = new File(fontLocation, FN_ALL_FONTS_LIST);
    // Current number of fonts is 103. Use the next round number to leave scope for more fonts
    // in the future.
    Set<String> allFontsList = new HashSet<String>(128);
    Scanner scanner = null;
    try {
        scanner = new Scanner(allFonts);
        while (scanner.hasNext()) {
            String name = scanner.next();
            // Skip font configuration files.
            if (!name.endsWith(".xml")) {
                allFontsList.add(name);
            }
        }
    } catch (FileNotFoundException e) {
        Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to load the list of fonts. Try re-installing the SDK Platform from the SDK Manager.", e, null);
    } finally {
        if (scanner != null) {
            scanner.close();
        }
    }
    SDK_FONTS = Collections.unmodifiableSet(allFontsList);
    for (FontFamily_Delegate fontFamily : sPostInitDelegate) {
        fontFamily.init();
    }
    sPostInitDelegate.clear();
}
Also used : Scanner(java.util.Scanner) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) HashSet(java.util.HashSet)

Example 92 with FileNotFoundException

use of java.io.FileNotFoundException in project platform_packages_apps_launcher by android.

the class Launcher method readConfiguration.

private static void readConfiguration(Context context, LocaleConfiguration configuration) {
    DataInputStream in = null;
    try {
        in = new DataInputStream(context.openFileInput(PREFERENCES));
        configuration.locale = in.readUTF();
        configuration.mcc = in.readInt();
        configuration.mnc = in.readInt();
    } catch (FileNotFoundException e) {
    // Ignore
    } catch (IOException e) {
    // Ignore
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
            // Ignore
            }
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream)

Example 93 with FileNotFoundException

use of java.io.FileNotFoundException in project platform_packages_apps_launcher by android.

the class Launcher method writeConfiguration.

private static void writeConfiguration(Context context, LocaleConfiguration configuration) {
    DataOutputStream out = null;
    try {
        out = new DataOutputStream(context.openFileOutput(PREFERENCES, MODE_PRIVATE));
        out.writeUTF(configuration.locale);
        out.writeInt(configuration.mcc);
        out.writeInt(configuration.mnc);
        out.flush();
    } catch (FileNotFoundException e) {
    // Ignore
    } catch (IOException e) {
        //noinspection ResultOfMethodCallIgnored
        context.getFileStreamPath(PREFERENCES).delete();
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            // Ignore
            }
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 94 with FileNotFoundException

use of java.io.FileNotFoundException in project platform_frameworks_base by android.

the class ActivityManagerService method openContentUri.

public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException {
    enforceNotIsolatedCaller("openContentUri");
    final int userId = UserHandle.getCallingUserId();
    String name = uri.getAuthority();
    ContentProviderHolder cph = getContentProviderExternalUnchecked(name, null, userId);
    ParcelFileDescriptor pfd = null;
    if (cph != null) {
        // We record the binder invoker's uid in thread-local storage before
        // going to the content provider to open the file.  Later, in the code
        // that handles all permissions checks, we look for this uid and use
        // that rather than the Activity Manager's own uid.  The effect is that
        // we do the check against the caller's permissions even though it looks
        // to the content provider like the Activity Manager itself is making
        // the request.
        Binder token = new Binder();
        sCallerIdentity.set(new Identity(token, Binder.getCallingPid(), Binder.getCallingUid()));
        try {
            pfd = cph.provider.openFile(null, uri, "r", null, token);
        } catch (FileNotFoundException e) {
        // do nothing; pfd will be returned null
        } finally {
            // Ensure that whatever happens, we clean up the identity state
            sCallerIdentity.remove();
            // Ensure we're done with the provider.
            removeContentProviderExternalUnchecked(name, null, userId);
        }
    } else {
        Slog.d(TAG, "Failed to get provider for authority '" + name + "'");
    }
    return pfd;
}
Also used : Binder(android.os.Binder) IBinder(android.os.IBinder) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) Point(android.graphics.Point)

Example 95 with FileNotFoundException

use of java.io.FileNotFoundException in project platform_frameworks_base by android.

the class PersistentDataStore method load.

private void load() {
    clearState();
    final InputStream is;
    try {
        is = mAtomicFile.openRead();
    } catch (FileNotFoundException ex) {
        return;
    }
    XmlPullParser parser;
    try {
        parser = Xml.newPullParser();
        parser.setInput(new BufferedInputStream(is), StandardCharsets.UTF_8.name());
        loadFromXml(parser);
    } catch (IOException ex) {
        Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
        clearState();
    } catch (XmlPullParserException ex) {
        Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
        clearState();
    } finally {
        IoUtils.closeQuietly(is);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)3572 IOException (java.io.IOException)2027 File (java.io.File)1415 FileInputStream (java.io.FileInputStream)906 InputStream (java.io.InputStream)535 FileOutputStream (java.io.FileOutputStream)522 BufferedReader (java.io.BufferedReader)301 FileReader (java.io.FileReader)267 ArrayList (java.util.ArrayList)232 Path (org.apache.hadoop.fs.Path)224 Test (org.junit.Test)212 InputStreamReader (java.io.InputStreamReader)193 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)189 XmlPullParser (org.xmlpull.v1.XmlPullParser)166 BufferedInputStream (java.io.BufferedInputStream)154 URL (java.net.URL)139 ParcelFileDescriptor (android.os.ParcelFileDescriptor)131 FileStatus (org.apache.hadoop.fs.FileStatus)131 Properties (java.util.Properties)129 HashMap (java.util.HashMap)120