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

The following examples show how to use mil.nga.geopackage.io.GeoPackageIOUtils#copyFile() . 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 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean copy(String database, String databaseCopy) {
    // Copy the database as a new file
    File dbFile = getFile(database);
    File dbCopyFile = context.getDatabasePath(databaseCopy);
    try {
        GeoPackageIOUtils.copyFile(dbFile, dbCopyFile);
    } catch (IOException e) {
        throw new GeoPackageException(
                "Failed to copy GeoPackage database '" + database
                        + "' to '" + databaseCopy + "'", e);
    }

    return exists(databaseCopy);
}
 
Example 2
Source File: ShareTask.java    From geopackage-mapcache-android with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected String doInBackground(Object... params) {

    File databaseFile = (File) params[0];
    String database = (String) params[1];

    // Copy the database to cache
    File cacheDirectory = getDatabaseCacheDirectory();
    cacheDirectory.mkdir();
    cacheFile = new File(cacheDirectory, database + "."
            + GeoPackageConstants.GEOPACKAGE_EXTENSION);
    try {
        GeoPackageIOUtils.copyFile(databaseFile, cacheFile);
    } catch (IOException e) {
        return e.getMessage();
    }

    return null;
}
 
Example 3
Source File: LoadGeoPackageTestCase.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws IOException
 * @throws SQLException
 */
@Override
protected GeoPackage getGeoPackage() throws Exception {
	File testFolder = folder.newFolder();

	File testFile = TestUtils.getTestFile(file);

	File newFile = new File(testFolder, testFile.getName());
	try {
		GeoPackageIOUtils.copyFile(testFile, newFile);
	} catch (IOException e) {
		throw new GeoPackageException(
				"Failed to copy GeoPackage to test directory. File: "
						+ testFile.getAbsolutePath() + ", Test Directory: "
						+ testFolder.getAbsolutePath(), e);
	}

	// Open
	GeoPackage geoPackage = GeoPackageManager.open(newFile);
	if (geoPackage == null) {
		throw new GeoPackageException("Failed to open database");
	}

	return geoPackage;
}
 
Example 4
Source File: ImportCoverageDataGeoPackageTestCase.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Get the import coverage data db file copied to the provided directory
 * 
 * @param directory
 * @return
 */
private File copyImportCoverageDataDbFile(File directory) {

	File file = TestUtils.getImportDbCoverageDataFile();

	File newFile = new File(directory, file.getName());
	try {
		GeoPackageIOUtils.copyFile(file, newFile);
	} catch (IOException e) {
		throw new GeoPackageException(
				"Failed to copy GeoPackage to test directory. File: "
						+ file.getAbsolutePath() + ", Test Directory: "
						+ directory.getAbsolutePath(), e);
	}
	return newFile;
}
 
Example 5
Source File: TestSetupTeardown.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Get the import db file copied to the provided directory
 * 
 * @param directory
 * @return
 */
private static File copyImportDbFile(File directory) {

	File file = TestUtils.getImportDbFile();

	File newFile = new File(directory, file.getName());
	try {
		GeoPackageIOUtils.copyFile(file, newFile);
	} catch (IOException e) {
		throw new GeoPackageException(
				"Failed to copy GeoPackage to test directory. File: "
						+ file.getAbsolutePath() + ", Test Directory: "
						+ directory.getAbsolutePath(),
				e);
	}
	return newFile;
}
 
Example 6
Source File: ImportCoverageDataTiffGeoPackageTestCase.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Get the import coverage data tiff db file copied to the provided directory
 * 
 * @param directory
 * @return
 */
private File copyImportCoverageDataTiffDbFile(File directory) {

	File file = TestUtils.getImportDbCoverageDataTiffFile();

	File newFile = new File(directory, file.getName());
	try {
		GeoPackageIOUtils.copyFile(file, newFile);
	} catch (IOException e) {
		throw new GeoPackageException(
				"Failed to copy GeoPackage to test directory. File: "
						+ file.getAbsolutePath() + ", Test Directory: "
						+ directory.getAbsolutePath(), e);
	}
	return newFile;
}