[gdal-dev] Gdal Java - Translate creates indestructible file
Vlad
vladimir.sandoval at yandex.com
Thu Mar 16 11:00:36 PDT 2017
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.
More information about the gdal-dev
mailing list