Almost indestructable.

Making a .png thumbnail...

public String produceThumbnail(Dataset ds, Path tempPath)
{
        Vector<String> optionsVector = new Vector<>();
        optionsVector.add("-of");
        optionsVector.add("PNG");
        optionsVector.add("-outsize");
        optionsVector.add("128");
        optionsVector.add("128");
        TranslateOptions options = new TranslateOptions(optionsVector);

        try
        {
            String name = tempPath + "/" + String.format("%s.%s",
RandomStringUtils.randomAlphanumeric(16), "png");
            org.gdal.gdal.gdal.Translate(name, ds, options);
            tmpFile = new File(name);
            if (tmpFile.exists())
            {
                //read in bytes to Base64 encoded String
                FileUtils.forceDelete(tempPath.toFile());
            }
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return theString;
}

It creates two files, a .png and a .png.aux.xml, and they are in the temp
directory passed in by tempPath.
NOTHING I try will delete the .png.  The FileUtils.forceDelete() does remove
the .png.aux.xml files, but not the .png, and hence, not the directory.  Any
deleteOnExit() does not remove anything.  I think I've tried every way there
is to delete a file in Java.

Is it possible the Translate() method is not closing a Stream somewhere?


V



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Gdal-Java-Translate-creates-indestructible-file-tp5312723.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to