Java Code Examples for mil.nga.geopackage.io.GeoPackageIOUtils#getFileNameWithoutExtension()

The following examples show how to use mil.nga.geopackage.io.GeoPackageIOUtils#getFileNameWithoutExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoPackageManagerImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean createFile(File file) {

    // Get the database name
    String database = GeoPackageIOUtils.getFileNameWithoutExtension(file);

    // Create the GeoPackage
    boolean created = createFile(database, file);

    return created;
}
 
Example 2
Source File: GeoPackageManagerImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean importGeoPackage(String name, File file, boolean override) {

    // Verify the file has the right extension
    GeoPackageValidate.validateGeoPackageExtension(file);

    // Use the provided name or the base file name as the database name
    String database;
    if (name != null) {
        database = name;
    } else {
        database = GeoPackageIOUtils.getFileNameWithoutExtension(file);
    }

    boolean success = false;
    try {
        FileInputStream geoPackageStream = new FileInputStream(file);
        success = importGeoPackage(database, override, geoPackageStream,
                null);
    } catch (FileNotFoundException e) {
        throw new GeoPackageException(
                "Failed read or write GeoPackage file '" + file
                        + "' to database: '" + database + "'", e);
    }

    return success;
}