1

I am unable to create File object while instantiate a tiff file using TestData.file function it is giving file not found exception . But the tif file is exist on the same path

file exists

Exception in thread "main" java.io.FileNotFoundException: Can not locate test-data for "images/no_crs.tif" at org.geotools.test.TestData.url(TestData.java:306) at org.geotools.test.TestData.file(TestData.java:328) at org.geotools.gce.geotiff.GeoTiffTest.main(GeoTiffTest.java:17)

here is my code

public class GeoTiffTest 
{
    public static void main(String[] args) throws FileNotFoundException, IOException 
    {
    File file = new File("images/no_crs.tif");
    if(file.exists())
            System.out.println("file exists");
    else
            System.out.println("file not exist");
        final File noCrs = TestData.file(GeoTiffTest.class, "images/no_crs.tif");
    }
}
0

TestData.file() is a special class for creating paths to files stored in a folder called test-data under the package name of your class in the resource folder. See http://docs.geotools.org/latest/developer/conventions/test/data.html for a full description of what it does. So if your file is in images/ then it won't be found using the path returned by TestData.file();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.