MCPcopy Create free account
hub / github.com/MinesJTK/jtk / ArrayFile

Class ArrayFile

core/src/main/java/edu/mines/jtk/io/ArrayFile.java:37–829  ·  view source on GitHub ↗

An array file expands the capabilities of java.io.RandomAccessFile. Specifically, an array file has methods for efficiently reading and writing arrays of primitive values, such as ints and floats. Also, array files may be read or written with either BIG_ENDIAN or LITTLE_ENDIAN byte orders. <

Source from the content-addressed store, hash-verified

35 * @version 2006.08.05
36 */
37public class ArrayFile implements ArrayInput, ArrayOutput, Closeable {
38
39 /**
40 * Constructs an array file with specified name and access mode.
41 * @param name the file name.
42 * @param mode the access mode; "r", "rw", "rws", or "rwd".
43 */
44 public ArrayFile(String name, String mode) throws FileNotFoundException {
45 this(name,mode,ByteOrder.BIG_ENDIAN,ByteOrder.BIG_ENDIAN);
46 }
47
48 /**
49 * Constructs an array file with specified file and access mode.
50 * @param file the file.
51 * @param mode the access mode; "r", "rw", "rws", or "rwd".
52 */
53 public ArrayFile(File file, String mode) throws FileNotFoundException {
54 this(file,mode,ByteOrder.BIG_ENDIAN,ByteOrder.BIG_ENDIAN);
55 }
56
57 /**
58 * Constructs an array file with specified name, access mode, and byte orders.
59 * @param name the file name.
60 * @param mode the access mode; "r", "rw", "rws", or "rwd".
61 * @param bor the byte order for reading.
62 * @param bow the byte order for writing.
63 */
64 public ArrayFile(String name, String mode, ByteOrder bor, ByteOrder bow)
65 throws FileNotFoundException
66 {
67 this(name!=null?new File(name):null,mode,bor,bow);
68 }
69
70 /**
71 * Constructs an array file with specified file, access mode, and byte orders.
72 * @param file the file.
73 * @param mode the access mode; "r", "rw", "rws", or "rwd".
74 * @param bor the byte order for reading.
75 * @param bow the byte order for writing.
76 */
77 public ArrayFile(File file, String mode, ByteOrder bor, ByteOrder bow)
78 throws FileNotFoundException
79 {
80 this(new RandomAccessFile(file,mode),bor,bow);
81 }
82
83 /**
84 * Constructs an array file for a specified random-access file
85 * and byte orders.
86 * @param raf the random-access file.
87 * @param bor the byte order for reading.
88 * @param bow the byte order for writing.
89 */
90 public ArrayFile(RandomAccessFile raf, ByteOrder bor, ByteOrder bow) {
91 _raf = raf;
92 _bor = bor;
93 _bow = bow;
94 _ai = new ArrayInputAdapter(raf,bor);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected