Package oms3.compiler
Class MemoryOutputJavaFileObject
- java.lang.Object
-
- javax.tools.SimpleJavaFileObject
-
- oms3.compiler.MemoryOutputJavaFileObject
-
- All Implemented Interfaces:
FileObject,JavaFileObject
public class MemoryOutputJavaFileObject extends SimpleJavaFileObject
A file object that retains contents in memory and does not write out to disk.- Author:
- prunge
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.tools.JavaFileObject
JavaFileObject.Kind
-
-
Field Summary
-
Fields inherited from class javax.tools.SimpleJavaFileObject
kind, uri
-
-
Constructor Summary
Constructors Constructor Description MemoryOutputJavaFileObject(URI uri, JavaFileObject.Kind kind)Constructs aMemoryOutputJavaFileObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStreamopenInputStream()Opens an input stream to the file data.OutputStreamopenOutputStream()Opens an output stream to write to the file.-
Methods inherited from class javax.tools.SimpleJavaFileObject
delete, getAccessLevel, getCharContent, getKind, getLastModified, getName, getNestingKind, isNameCompatible, openReader, openWriter, toString, toUri
-
-
-
-
Constructor Detail
-
MemoryOutputJavaFileObject
public MemoryOutputJavaFileObject(URI uri, JavaFileObject.Kind kind)
Constructs aMemoryOutputJavaFileObject.- Parameters:
uri- the URI of the output file.kind- the file type.
-
-
Method Detail
-
openOutputStream
public OutputStream openOutputStream() throws IOException
Opens an output stream to write to the file. This writes to memory. This clears any existing output in the file.- Specified by:
openOutputStreamin interfaceFileObject- Overrides:
openOutputStreamin classSimpleJavaFileObject- Returns:
- an output stream.
- Throws:
IOException- if an I/O error occurs.
-
openInputStream
public InputStream openInputStream() throws IOException
Opens an input stream to the file data. If the file has never been written the input stream will contain no data (i.e. length=0).- Specified by:
openInputStreamin interfaceFileObject- Overrides:
openInputStreamin classSimpleJavaFileObject- Returns:
- an input stream.
- Throws:
IOException- if an I/O error occurs.
-
-