本文整理了Java中it.geosolutions.imageio.utilities.Utilities
类的一些代码示例,展示了Utilities
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities
类的具体详情如下:
包路径:it.geosolutions.imageio.utilities.Utilities
类名称:Utilities
[英]Simple class for utility methods.
[中]实用程序方法的简单类。
代码示例来源:origin: geotools/geotools
if (protocol.equalsIgnoreCase("file")) {
try {
File file = it.geosolutions.imageio.utilities.Utilities.urlToFile(tempURL);
paramInput = new FileImageInputStreamExtImpl(file);
} catch (IOException e) {
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-netcdf
attributeName = Utilities.adjustAttributeName(attributeName);
node.setAttribute(attributeName, attributeValue);
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-test-data
/**
* Access to <code>{@linkplain #getResource getResource}(caller, path)</code> as a non-null
* {@link File}. You can access the {@code test-data} directory with:
*
* <blockquote><pre>
* TestData.file(MyClass.class, null);
* </pre></blockquote>
*
* @param caller Calling class or object used to locate {@code test-data}.
* @param path Path to file in {@code test-data}.
* @return The file to the {@code test-data} resource.
* @throws FileNotFoundException if the file is not found.
* @throws IOException if the resource can't be fetched for an other reason.
*/
public static File file(final Object caller, final String path) throws IOException {
final URL url = url(caller, path);
final File file = Utilities.urlToFile(url);
if (!file.exists()) {
throw new FileNotFoundException("Could not locate test-data: " + path);
}
return file;
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-gdalframework
/**
* Sets the destination to the given <code>Object</code>, usually a
* <code>File</code> or a {@link FileImageOutputStreamExt}.
*
* @param output
* the <code>Object</code> to use for future writing.
*/
public void setOutput(Object output) {
super.setOutput(output); // validates output
if (output instanceof File)
outputFile = (File) output;
else if (output instanceof FileImageOutputStreamExt)
outputFile = ((FileImageOutputStreamExt) output).getFile();
else if (output instanceof URL) {
final URL tempURL = (URL) output;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
outputFile = Utilities.urlToFile(tempURL);
}
else
throw new IllegalArgumentException("Not a Valid Input");
}
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-test-data
/**
* Provides a channel for named test data. It is the caller responsability to close this
* chanel after usage.
*
* @param caller The class of the object associated with named data.
* @param name of test data to load.
* @return The chanel.
* @throws FileNotFoundException if the resource is not found.
* @throws IOException if an error occurs during an input operation.
*
* @since 2.2
*/
public static ReadableByteChannel openChannel(final Object caller, final String name)
throws IOException
{
final URL url = url(caller, name);
final File file = Utilities.urlToFile(url);
if (file.exists()) {
return new RandomAccessFile(file, "r").getChannel();
}
return Channels.newChannel(url.openStream());
}
代码示例来源:origin: geosolutions-it/imageio-ext
/**
* Sets the destination to the given <code>Object</code>, usually a
* <code>File</code> or a {@link FileImageOutputStreamExt}.
*
* @param output
* the <code>Object</code> to use for future writing.
*/
public void setOutput(Object output) {
super.setOutput(output); // validates output
if (output instanceof File)
outputFile = (File) output;
else if (output instanceof FileImageOutputStreamExt)
outputFile = ((FileImageOutputStreamExt) output).getFile();
else if (output instanceof URL) {
final URL tempURL = (URL) output;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
outputFile = Utilities.urlToFile(tempURL);
}
else
throw new IllegalArgumentException("Not a Valid Input");
}
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-gdalframework
/**
* Tries to retrieve the Dataset Source for the ImageReader's input.
*/
protected File getDatasetSource(Object myInput) {
if (datasetSource == null) {
if (myInput instanceof File)
datasetSource = (File) myInput;
else if (myInput instanceof FileImageInputStreamExt)
datasetSource = ((FileImageInputStreamExt) myInput).getFile();
else if (input instanceof URL) {
final URL tempURL = (URL) input;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
datasetSource = Utilities.urlToFile(tempURL);
}
else
throw new IllegalArgumentException("Not a supported Input");
} else
// should never happen
throw new RuntimeException(
"Unable to retrieve the Data Source for"
+ " the provided input");
}
return datasetSource;
}
代码示例来源:origin: geosolutions-it/imageio-ext
/**
* Access to <code>{@linkplain #getResource getResource}(caller, path)</code> as a non-null
* {@link File}. You can access the {@code test-data} directory with:
*
* <blockquote><pre>
* TestData.file(MyClass.class, null);
* </pre></blockquote>
*
* @param caller Calling class or object used to locate {@code test-data}.
* @param path Path to file in {@code test-data}.
* @return The file to the {@code test-data} resource.
* @throws FileNotFoundException if the file is not found.
* @throws IOException if the resource can't be fetched for an other reason.
*/
public static File file(final Object caller, final String path) throws IOException {
final URL url = url(caller, path);
final File file = Utilities.urlToFile(url);
if (!file.exists()) {
throw new FileNotFoundException("Could not locate test-data: " + path);
}
return file;
}
代码示例来源:origin: geosolutions-it/imageio-ext
/**
* Provides a channel for named test data. It is the caller responsability to close this
* chanel after usage.
*
* @param caller The class of the object associated with named data.
* @param name of test data to load.
* @return The chanel.
* @throws FileNotFoundException if the resource is not found.
* @throws IOException if an error occurs during an input operation.
*
* @since 2.2
*/
public static ReadableByteChannel openChannel(final Object caller, final String name)
throws IOException
{
final URL url = url(caller, name);
final File file = Utilities.urlToFile(url);
if (file.exists()) {
return new RandomAccessFile(file, "r").getChannel();
}
return Channels.newChannel(url.openStream());
}
代码示例来源:origin: geosolutions-it/imageio-ext
/**
* Tries to retrieve the Dataset Source for the ImageReader's input.
*/
protected File getDatasetSource(Object myInput) {
if (datasetSource == null) {
if (myInput instanceof File)
datasetSource = (File) myInput;
else if (myInput instanceof FileImageInputStreamExt)
datasetSource = ((FileImageInputStreamExt) myInput).getFile();
else if (input instanceof URL) {
final URL tempURL = (URL) input;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
datasetSource = Utilities.urlToFile(tempURL);
}
else
throw new IllegalArgumentException("Not a supported Input");
} else
// should never happen
throw new RuntimeException(
"Unable to retrieve the Data Source for"
+ " the provided input");
}
return datasetSource;
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-customstreams
/**
*
* @see javax.imageio.spi.ImageInputStreamSpi#createInputStreamInstance(java.lang.Object,
* boolean, java.io.File)
*/
public ImageInputStream createInputStreamInstance(Object input,
boolean useCache, File cacheDir) {
// is it a URL?
if (!(input instanceof URL)) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine("The provided input is not a valid URL.");
return null;
}
try {
// URL that points to a file?
final URL sourceURL = ((URL) input);
final File tempFile = Utilities.urlToFile(sourceURL);
if (tempFile.exists() && tempFile.isFile() && tempFile.canRead())
return fileStreamSPI.createInputStreamInstance(tempFile,useCache, cacheDir);
// URL that does NOT points to a file, let's open up a stream
if (useCache)
return new MemoryCacheImageInputStream(sourceURL.openStream());
else
return new FileCacheImageInputStream(sourceURL.openStream(), cacheDir);
} catch (IOException e) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
return null;
}
}
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-customstreams
File tempFile;
try {
tempFile = Utilities.urlToFile(outputURL);
return new FileImageOutputStreamExtImpl(tempFile);
} catch (UnsupportedEncodingException e) {
代码示例来源:origin: geosolutions-it/imageio-ext
File tempFile;
try {
tempFile = Utilities.urlToFile(outputURL);
return new FileImageOutputStreamExtImpl(tempFile);
} catch (UnsupportedEncodingException e) {
代码示例来源:origin: geosolutions-it/imageio-ext
File tempFile;
try {
tempFile = Utilities.urlToFile(tempURL);
return new FileImageOutputStreamExtImpl(tempFile);
} catch (UnsupportedEncodingException e) {
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-customstreams
File tempFile;
try {
tempFile = Utilities.urlToFile(tempURL);
return new FileImageOutputStreamExtImpl(tempFile);
} catch (UnsupportedEncodingException e) {
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-arcgrid
final File inFile = Utilities.urlToFile(testUrl);
if (!inFile.exists()) {
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-kakadu
final URL tempURL = (URL) input;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
source = Utilities.urlToFile(tempURL);
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-arcgrid
final URL tempURL = (URL) input;
if (tempURL.getProtocol().equalsIgnoreCase("file"))
input = Utilities.urlToFile(tempURL);
else
input = ((URL) input).openStream();
代码示例来源:origin: org.geotools/gt-coverage-api
if (protocol.equalsIgnoreCase("file")) {
try {
File file = it.geosolutions.imageio.utilities.Utilities.urlToFile(tempURL);
paramInput = new FileImageInputStreamExtImpl(file);
} catch (IOException e) {
代码示例来源:origin: it.geosolutions.imageio-ext/imageio-ext-kakadu
final URL tempURL = (URL) input;
if (tempURL.getProtocol().equalsIgnoreCase("file")) {
inputFile = Utilities.urlToFile(tempURL);
内容来源于网络,如有侵权,请联系作者删除!