public abstract class Resource extends Object implements Closeable
Modifier and Type | Class and Description |
---|---|
static class |
Resource.Type
Identifies the content type of a resource.
|
Modifier | Constructor and Description |
---|---|
protected |
Resource(File location)
Creates a new Resource instance.
|
protected |
Resource(URL location)
Creates a new Resource instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected URL |
getLocation()
Returns the location of this resource.
|
Resource.Type |
getType()
Returns the content type of this resource.
|
protected InputStream |
openInput()
Opens a stream to read the contents of this resource.
|
protected OutputStream |
openOutput()
Opens a stream to write the contents of this resource.
|
void |
setType(Resource.Type type)
Changes the content type of this resource.
|
String |
toString() |
static URL |
urlFor(File file)
Returns the URL for the given file.
|
static File |
withDefaultType(File file,
Resource.Type defaultType)
Returns the given file name, assigning the default type if no type defined.
|
static <T extends Resource> |
withDefaultType(T resource,
Resource.Type defaultType)
Returns the given resource, assigning the default type if no type yet defined.
|
protected Resource(URL location)
protected Resource(File location)
protected URL getLocation()
public void setType(Resource.Type type)
public Resource.Type getType()
protected InputStream openInput()
protected OutputStream openOutput()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public static <T extends Resource> T withDefaultType(T resource, Resource.Type defaultType)
public static File withDefaultType(File file, Resource.Type defaultType)
Copyright © 2024 The Cornutum Project. All rights reserved.