/** * Probes the given file by delegating to {@link DataStores#probeContentType(Object)}. * * @param path the path to the file to probe. * @return the content type or {@code null} if the file type is not recognized. * @throws IOException if an I/O error occurs while reading the file. * * @see java.nio.file.Files#probeContentType(Path) */ @Override public String probeContentType(final Path path) throws IOException { try { return DataStores.probeContentType(path); } catch (DataStoreException e) { final Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw new IOException(e); } } }
/** * Probes the given file by delegating to {@link DataStores#probeContentType(Object)}. * * @param path the path to the file to probe. * @return the content type or {@code null} if the file type is not recognized. * @throws IOException if an I/O error occurs while reading the file. * * @see java.nio.file.Files#probeContentType(Path) */ @Override public String probeContentType(final Path path) throws IOException { try { return DataStores.probeContentType(path); } catch (DataStoreException e) { final Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw new IOException(e); } } }
/** * Closes this data store and releases any underlying resources. * * @throws DataStoreException if an error occurred while closing this data store. */ @Override public synchronized void close() throws DataStoreException { final Reader r = reader; reader = null; if (r != null) try { r.close(); } catch (Exception e) { final DataStoreException ds = new DataStoreException(e); try { super.close(); } catch (DataStoreException s) { ds.addSuppressed(s.getCause()); } throw ds; } super.close(); } }