diff options
author | mihaylov <mihaylov@epfl.ch> | 2004-04-23 14:51:44 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2004-04-23 14:51:44 +0000 |
commit | 873dd15e7406c743d6d178e18043558a3422502c (patch) | |
tree | 8990bd745c7d9f3f9bba3625f4810e295d1ac049 /sources | |
parent | 92fcc53be94a107f3b560b855564bc39ba8f2372 (diff) | |
download | scala-873dd15e7406c743d6d178e18043558a3422502c.tar.gz scala-873dd15e7406c743d6d178e18043558a3422502c.tar.bz2 scala-873dd15e7406c743d6d178e18043558a3422502c.zip |
- Initial import of the class.
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/util/ByteArrayFile.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sources/scala/tools/util/ByteArrayFile.java b/sources/scala/tools/util/ByteArrayFile.java new file mode 100644 index 0000000000..afbc9ce089 --- /dev/null +++ b/sources/scala/tools/util/ByteArrayFile.java @@ -0,0 +1,54 @@ +/* ____ ____ ____ ____ ______ *\ +** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** +** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** +** /_____/\____/\___/\____/____/ ** +\* */ + +// $Id$ + +package scala.tools.util; + +/** + * This class implements an abstract regular file backed by a + * character array. + */ +public class ByteArrayFile extends VirtualFile { + + //######################################################################## + // Private Fields + + /** The character array */ + private final byte[] bytes; + + //######################################################################## + // Public Constructors + + /** + * Initializes this instance with the specified name, an identical + * path and the specified character array. + */ + public ByteArrayFile(String name, byte[] bytes) { + this(name, name, bytes); + } + + /** + * Initializes this instance with the specified name, path and + * character array. + */ + public ByteArrayFile(String name, String path, byte[] bytes) { + super(name, path); + this.bytes = bytes; + } + + //######################################################################## + // Public Methods + + /** Reads the content of this abstract file into a byte array. */ + public byte[] read() { + byte[] newBytes = new byte[bytes.length]; + System.arraycopy(bytes, 0, newBytes, 0, bytes.length); + return newBytes; + } + + //######################################################################## +} |