25package umontreal.ssj.util.io;
80 protected DataOutputStream out;
88 out.writeInt(s.length());
148 this.out =
new DataOutputStream(
new FileOutputStream(filename, append));
159 this.out =
new DataOutputStream(
new FileOutputStream(file, append));
168 this.out =
new DataOutputStream(
new FileOutputStream(filename));
177 this.out =
new DataOutputStream(
new FileOutputStream(file));
186 this.out =
new DataOutputStream(outputStream);
197 public void write(String label, String s)
throws IOException {
208 public void write(String label,
int a)
throws IOException {
219 public void write(String label,
float a)
throws IOException {
230 public void write(String label,
double a)
throws IOException {
249 public void write(String label, String[] a,
int n)
throws IOException {
254 for (
int i = 0; i < n; i++)
262 public void write(String label,
int[] a,
int n)
throws IOException {
267 for (
int i = 0; i < n; i++)
275 public void write(String label,
float[] a,
int n)
throws IOException {
280 for (
int i = 0; i < n; i++)
281 out.writeFloat(a[i]);
288 public void write(String label,
double[] a,
int n)
throws IOException {
293 for (
int i = 0; i < n; i++)
294 out.writeDouble(a[i]);
309 public void write(String label, String[][] a)
throws IOException {
313 out.writeInt(a.length);
314 out.writeInt(a[0].length);
315 for (
int i = 0; i < a.length; i++)
316 for (
int j = 0; j < a[i].length; j++)
324 public void write(String label,
int[][] a)
throws IOException {
328 out.writeInt(a.length);
329 out.writeInt(a[0].length);
330 for (
int i = 0; i < a.length; i++)
331 for (
int j = 0; j < a[i].length; j++)
332 out.writeInt(a[i][j]);
339 public void write(String label,
float[][] a)
throws IOException {
343 out.writeInt(a.length);
344 out.writeInt(a[0].length);
345 for (
int i = 0; i < a.length; i++)
346 for (
int j = 0; j < a[i].length; j++)
347 out.writeFloat(a[i][j]);
354 public void write(String label,
double[][] a)
throws IOException {
358 out.writeInt(a.length);
359 out.writeInt(a[0].length);
360 for (
int i = 0; i < a.length; i++)
361 for (
int j = 0; j < a[i].length; j++)
362 out.writeDouble(a[i][j]);
376 public void close() throws IOException {
This abstract class implements shared functionality for data writers.
static final byte TYPECHAR_DOUBLE
Field-type symbol indicating double data.
static final byte TYPECHAR_FLOAT
Field-type symbol indicating float data.
void write(String label, int a)
Writes an atomic 32-bit integer (big endian).
void write(String label, int[][] a)
Writes a two-dimensional array of 32-bit integers (big endian).
void write(String label, float[] a, int n)
Writes the first n elements of a one-dimensional array of 32-bit floats (big endian).
BinaryDataWriter(File file)
Truncates any existing file with the specified name.
void write(String label, String[] a, int n)
Writes the first n elements of a one-dimensional array of strings.
BinaryDataWriter(OutputStream outputStream)
Constructor.
BinaryDataWriter(String filename)
Truncates any existing file with the specified name.
void write(String label, String s)
Writes an atomic string field.
static final byte TYPECHAR_LABEL
Field-type symbol indicating a label (it more accurately a field separator symbol).
void close()
Flushes any pending data and closes the file.
void write(String label, float a)
Writes an atomic 32-bit float (big endian).
void write(String label, int[] a, int n)
Writes the first n elements of a one-dimensional array of 32-bit integers (big endian).
void writeLabel(String label)
Starts a new field by writing its label.
static final byte TYPECHAR_STRING
Field-type symbol indicating String data.
void write(String label, double[] a, int n)
Writes the first n elements of a one-dimensional array of 64-bit doubles (big endian).
void write(String label, String[][] a)
Writes a two-dimensional array of strings.
void write(String label, double[][] a)
Writes a two-dimensional array of 64-bit doubles (big endian).
void writeStringData(String s)
Utility method to write string data.
static final byte TYPECHAR_INTEGER
Field-type symbol indicating int data.
void write(String label, float[][] a)
Writes a two-dimensional array of 32-bit floats (big endian).
BinaryDataWriter(File file, boolean append)
Data will be output to the specified file.
void write(String label, double a)
Writes an atomic 64-bit double (big endian).
BinaryDataWriter(String filename, boolean append)
Data will be output to the file with the specified name.