Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/org/scijava/io/handle/DataHandleService.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.scijava.io.handle;

import java.io.IOException;

import org.scijava.io.IOService;
import org.scijava.io.location.Location;
import org.scijava.plugin.WrapperService;
Expand Down Expand Up @@ -63,4 +65,18 @@ default Class<DataHandle<Location>> getPluginType() {
default Class<Location> getType() {
return Location.class;
}

/**
* Convenience method to test whether it describes an existing file.
*
* @param location the location to test
* @return The result of {@link DataHandle#exists()} on a newly created handle
* on this location
* @throws IOException
*/
default boolean exists(final Location location) throws IOException {
try (DataHandle<Location> handle = create(location)) {
return handle.exists();
}
}
}