1 /*
2 * Copyright (C) 2012 Alberto Irurueta Carro (alberto@irurueta.com)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.geometry.io;
17
18 import java.io.Closeable;
19 import java.io.IOException;
20
21 /**
22 * Abstract class that provides methods to access file data at random positions.
23 */
24 public abstract class AbstractFileReaderAndWriter implements Closeable {
25
26 /**
27 * Reads one byte at current file position and advances one position.
28 *
29 * @return Next byte of data or -1 if end of file is reached.
30 * @throws IOException if an I/O error occurs. Not thrown if end-of-file has
31 * been reached.
32 */
33 public abstract int read() throws IOException;
34
35 /**
36 * Reads up to b.length bytes of data from this file into an array of bytes.
37 * This method blocks until at least one byte of input is available.
38 *
39 * @param b The buffer into which the data is read.
40 * @return The total number of bytes read into the buffer, or -1 if there is
41 * no more data because the end of the file has been reached.
42 * @throws IOException If the first byte cannot be read for any reason other
43 * than end of file, or if the file has been closed, or if some other I/O
44 * error occurs.
45 */
46 public abstract int read(final byte[] b) throws IOException;
47
48 /**
49 * Reads up to len bytes of data from this file into an array of bytes. This
50 * method blocks until at least one byte of input is available.
51 * This method behaves in exactly the same way as the
52 * InputStream.read(byte[], int, int) method of InputStream.
53 *
54 * @param b the buffer into which the data is read.
55 * @param off the start offset in array b at which the data is written.
56 * @param len the maximum number of bytes read.
57 * @return the total number of bytes read into the buffer, or -1 if there is
58 * no more data because the end of the file has been reached.
59 * @throws IOException If the first byte cannot be read for any reason other
60 * than end of file, or if the random access file has been closed, or if
61 * some other I/O error occurs.
62 */
63 public abstract int read(final byte[] b, final int off, final int len) throws IOException;
64
65 /**
66 * Attempts to skip over n byte of input discarding the skipped bytes.
67 * <p>
68 * This method may skip over some number of bytes, possibly zero. This may
69 * result from any of a number of conditions; reaching end of file before n
70 * bytes have been skipped is only one possibility. The actual number of
71 * bytes skipped is returned. If n is negative, no bytes are skipped.
72 *
73 * @param n the number of bytes to be skipped.
74 * @return the actual number of bytes skipped.
75 * @throws IOException if an I/O error occurs.
76 */
77 public abstract long skip(final long n) throws IOException;
78
79 /**
80 * Writes the specified byte to this file. The write starts at the current
81 * file pointer.
82 *
83 * @param b the byte to be written.
84 * @throws IOException if an I/O error occurs.
85 */
86 public abstract void write(final int b) throws IOException;
87
88 /**
89 * Writes b.length bytes from the specified byte array to this file,
90 * starting at the current file pointer.
91 *
92 * @param b the data.
93 * @throws IOException if an I/O error occurs.
94 */
95 public abstract void write(final byte[] b) throws IOException;
96
97 /**
98 * Writes len bytes from the specified byte array starting at offset off to
99 * this file.
100 *
101 * @param b the data.
102 * @param off the start offset in the data.
103 * @param len the number of bytes to write.
104 * @throws IOException if an I/O error occurs.
105 */
106 public abstract void write(final byte[] b, final int off, final int len) throws IOException;
107
108 /**
109 * Returns the current offset in this file.
110 *
111 * @return the offset from the beginning of the file, in bytes, at which the
112 * next read or write occurs.
113 * @throws IOException in an I/O error occurs.
114 */
115 public abstract long getPosition() throws IOException;
116
117 /**
118 * Determines whether end of file has been reached (next read() will return
119 * -1). or not.
120 *
121 * @return True if end of file has been reached, false otherwise.
122 * @throws IOException if an I/O error occurs.
123 */
124 public abstract boolean isEndOfStream() throws IOException;
125
126 /**
127 * Sets the file-pointer offset, measured from the beginning of this file,
128 * at which the next read or write occurs. The offset may be set beyond the
129 * end of the file. Setting the offset beyond the end of the file does not
130 * change the file length.
131 * The file length will change only by writing after the offset has been set
132 * beyond the end of the file.
133 *
134 * @param pos the offset position, measured in bytes from the beginning of
135 * the file, at which to set the file pointer.
136 * @throws IOException if pos is less than 0 or if an I/O error occurs.
137 */
138 public abstract void seek(final long pos) throws IOException;
139
140 /**
141 * Reads a boolean from this file. This method reads a single byte from the
142 * file, starting at the current file pointer. A value of 0 represents
143 * false. Any other value represents true. This method blocks until the byte
144 * is read, the end of the stream is detected, or an exception is thrown.
145 *
146 * @return the boolean value read.
147 * @throws IOException if an I/O error occurs.
148 */
149 public abstract boolean readBoolean() throws IOException;
150
151 /**
152 * Reads a signed eight-bit value from this file. This method reads a byte
153 * from the file, starting from the current file pointer. If the byte read
154 * is b, where 0 <= b <= 255, then the result is: (byte)(b)
155 * This method blocks until the byte is read, the end of the stream is
156 * detected, or an exception is thrown.
157 *
158 * @return the next byte of this file is a signed eight-bit byte.
159 * @throws IOException if an I/O error occurs.
160 */
161 public abstract byte readByte() throws IOException;
162
163 /**
164 * Reads an unsigned eight-bit number from this file. This method reads a
165 * byte from this file, starting at the current file pointer, and returns
166 * that byte.
167 * This method blocks until the byte is read, the end of the stream is
168 * detected, or an exception is thrown.
169 *
170 * @return the next byte of this file, interpreted as an unsigned eight-bit
171 * number.
172 * @throws IOException if an I/O error occurs.
173 */
174 public abstract short readUnsignedByte() throws IOException;
175
176 /**
177 * Reads a signed 16-bit number from this file. The method reads two byte
178 * from this file, starting at the current file pointer. If the two bytes
179 * read, in order, are b1 and b2, where each of the two values is between 0
180 * and 255, inclusive, then the result is equal to: (short)(b1 << 8 |
181 * b2).
182 * This method blocks until the two bytes are read, the end of the stream is
183 * detected, or an exception is thrown.
184 *
185 * @return the next two bytes of this file, interpreted as a signed 16-bit
186 * number.
187 * @throws IOException if an I/O error occurs.
188 */
189 public abstract short readShort() throws IOException;
190
191 /**
192 * Reads a signed 16-bit number from this file assuming that file is encoded
193 * using provided endian type. If endian type is big endian type, then
194 * natural binary order is preserved, otherwise byte order is reversed.
195 * This method blocks until the two bytes of the 16-bit number are read, the
196 * end of the stream is detected, or an exception is thrown.
197 *
198 * @param endianType Endian type. Big endian preserves natural binary order,
199 * little endian reverses byte order.
200 * @return the next two bytes of this file, interpreted as a signed 16-bit
201 * number encoded in provided endian type.
202 * @throws IOException if an I/O error occurs.
203 */
204 public abstract short readShort(final EndianType endianType) throws IOException;
205
206 /**
207 * Reads an unsigned 16-bit number from this file. This method reads two
208 * bytes from this file, starting at the current file pointer. If the bytes
209 * read, in order, are b1 and b2, where 0 <= b1, b2 <= 255, then the
210 * result is equal to: (b1 << 8) | b2
211 * This method blocks until the two bytes are read, the end of the stream is
212 * detected, or an exception is thrown.
213 *
214 * @return the next two bytes of this file, interpreted as an unsigned
215 * 16-bit integer.
216 * @throws IOException if an I/O error occurs.
217 */
218 public abstract int readUnsignedShort() throws IOException;
219
220 /**
221 * Reads an unsigned 16-bit number from this file. This method reads two
222 * bytes from this file, starting at the current file pointer and using
223 * provided endian type. If endian type is big endian, then natural binary
224 * order is preserved, otherwise byte order is reversed.
225 * This method blocks until the two bytes are read, the end of the stream is
226 * detected, or an exception is thrown.
227 *
228 * @param endianType Endian type. Big endian preserves natural binary order,
229 * little endian reverses byte order.
230 * @return the next two bytes of this file, interpreted as an unsigned
231 * 16-bit integer.
232 * @throws IOException if an I/O error occurs.
233 */
234 public abstract int readUnsignedShort(final EndianType endianType)
235 throws IOException;
236
237 /**
238 * Reads a signed 32-bit integer from this file. This method reads 4 bytes
239 * from the file, starting at the current file pointer. If the bytes read,
240 * in order, are b1, b2, b3, and b4, where 0 <= b1, b3, b4 <= 255, then
241 * the result is equal to: (b1 << 24) | (b2 << 16) + (b3 << 8) +
242 * b4.
243 * This method blocks until the four bytes are read, the end of the stream
244 * is detected, or an exception is thrown.
245 *
246 * @return the next four bytes of this file, interpreted as an int.
247 * @throws IOException if an I/O error occurs.
248 */
249 public abstract int readInt() throws IOException;
250
251 /**
252 * Reads a signed 32-bit integer from this file. This method reads 4 bytes
253 * from the file, starting at the current file pointer and using provided
254 * endian type. If endian type is big endian, then natural binary order is
255 * preserved, otherwise byte order is reversed.
256 * This method blocks until the four bytes are read, the end of the stream
257 * is detected, or an exception is thrown.
258 *
259 * @param endianType Endian type. Big endian preserves natural binary order,
260 * little endian reverses byte order.
261 * @return the next four bytes of this file, interpreted as an int.
262 * @throws IOException if an I/O error occurs.
263 */
264 public abstract int readInt(final EndianType endianType) throws IOException;
265
266 /**
267 * Reads an unsigned 32-bit integer from this file. This method reads 4
268 * bytes from the file, starting at the current file pointer. If the bytes
269 * read, in order, are b1, b2, b3, and b4, where 0 <= b1, b3, b4 <= 255,
270 * then the result is equal to: (b1 << 24) | (b2 << 16) +
271 * (b3 << 8) + b4
272 * This method blocks until the four bytes are read, the end of the stream
273 * is detected, or an exception is thrown.
274 *
275 * @return the next four bytes of this file, interpreted as a long.
276 * @throws IOException if an I/O error occurs.
277 */
278 public abstract long readUnsignedInt() throws IOException;
279
280 /**
281 * Reads an unsigned 32-bit integer from this file. This method reads 4
282 * bytes from the file, starting at the current file pointer and using
283 * provided endian type. If endian type is big endian, then natural binary
284 * order is preserved, otherwise byte order is reversed.
285 * This method blocks until the four bytes are read, the end of the stream
286 * is detected, or an exception is thrown.
287 *
288 * @param endianType Endian type. Big endian preserves natural binary order,
289 * little endian reverses byte order.
290 * @return the next four bytes of this file, interpreted as an int.
291 * @throws IOException if an I/O error occurs.
292 */
293 public abstract long readUnsignedInt(final EndianType endianType)
294 throws IOException;
295
296 /**
297 * Reads a signed 64-bit integer from this file. This method reads eight
298 * bytes from the file, starting at the current file pointer. If the bytes
299 * read, in order, are b1, b2, b3, b4, b5, b6, b7, and b8, where:
300 * 0 <= b1, b2, b3, b4. b5. b6. b7. b8 <= 255,
301 * then the result is equal to:
302 * ((long)b1 << 56) + ((long)b2 << 48)
303 * + ((long)b3 << 40) + ((long)b4 << 32)
304 * + ((long)b5 << 24) + ((long)b6 << 16)
305 * + ((long)b7 << 8) + b8
306 * This method blocks until the eight bytes are read, the end of the stream
307 * is detected, or an exception is thrown.
308 *
309 * @return the next eight bytes of this file, interpreted as a long.
310 * @throws IOException if an I/O error occurs.
311 */
312 public abstract long readLong() throws IOException;
313
314 /**
315 * Reads a signed 64-bit integer from this file. This method reads eight
316 * bytes from the file, starting at the current file pointer and using
317 * provided endian type. If endian type is big endian, then natural binary
318 * order is preserved, otherwise byte order is reversed.
319 * This method blocks until the eight bytes are read, the end of the stream
320 * is detected, or an exception is thrown.
321 *
322 * @param endianType Endian type. Big endian preserves natural binary order,
323 * little endian reverses byte order.
324 * @return the next eight bytes of this file, interpreted as a long
325 * @throws IOException if an I/O error occurs.
326 */
327 public abstract long readLong(final EndianType endianType) throws IOException;
328
329 /**
330 * Reads a float from this file. This method reads an int value, starting at
331 * the current file pointer, as if by the readInt method and then converts
332 * that in to a float using the intBitsToFloat method in class Float.
333 * This method blocks until the four bytes are read, the end of the stream
334 * is detected, or an exception is thrown.
335 *
336 * @return the next four bytes of this file, interpreted as a float.
337 * @throws IOException if an I/O error occurs.
338 */
339 public abstract float readFloat() throws IOException;
340
341 /**
342 * Reads a float from this file. This method reads four bytes using
343 * provided endian type. If endian type is big endian, then natural binary
344 * order is preserved, otherwise byte order is reversed.
345 * This method blocks until the four bytes are read, the end of the stream
346 * is detected, or an exception is thrown.
347 *
348 * @param endianType Endian type. Big endian preserves natural binary order,
349 * little endian reverses byte order.
350 * @return the next four bytes of this file, interpreted as a float.
351 * @throws IOException if an I/O error occurs.
352 */
353 public abstract float readFloat(final EndianType endianType) throws IOException;
354
355 /**
356 * Reads a double from this file. This method reads a long value, starting
357 * at the current file pointer, as if by the readLong method and then
358 * converts that long to a double using the longBitsToDouble method in class
359 * Double.
360 * This method blocks until the eight bytes are read, the end of the stream
361 * is detected, or an exception is thrown.
362 *
363 * @return the next eight bytes of this file, interpreted as a double.
364 * @throws IOException if an I/O error occurs.
365 */
366 public abstract double readDouble() throws IOException;
367
368 /**
369 * Reads a double from this file. This method reads eight bytes using
370 * provided endian type. If endian type is big endian, then natural binary
371 * order is preserved, otherwise byte order is reversed.
372 * This method blocks until the eight bytes are read, the end of the stream
373 * is detected, or an exception is thrown.
374 *
375 * @param endianType Endian type. Big endian preserves natural binary order,
376 * little endian reverses byte order.
377 * @return the next eight bytes of this file, interpreted as a double.
378 * @throws IOException if an I/O error occurs.
379 */
380 public abstract double readDouble(final EndianType endianType) throws IOException;
381
382 /**
383 * Reads the next line of text from this file. This method successively
384 * reads bytes from the file, starting at the current file pointer, until it
385 * reaches a line terminator of the end of the file. Each byte is converted
386 * into a character by taking the byte's value for the lower eight bits of
387 * the character and setting the high eight bits of the character to zero.
388 * This method does not, therefore, support the full Unicode character set.
389 * A line of text is terminated by a carriage-return character ('\r'), a
390 * newline character('\n'), a carriage-return character immediately followed
391 * by a newline character, or the end of the file. Line-terminating
392 * characters are discarded and are not included as part of the string
393 * returned.
394 * This method blocks until a newline character is read, a carriage return
395 * and the byte following it are read (to see if it is a newline), the end
396 * of the file is reached, or an exception is thrown.
397 *
398 * @return the next line of text from this file, or null if end of file is
399 * encountered before even one byte is read.
400 * @throws IOException if an I/O error occurs.
401 */
402 public abstract String readLine() throws IOException;
403
404 /**
405 * Sequentially reads characters starting at current file position until
406 * either carriage return, new line, tab or space character is found.
407 * The result is considered a word and it is returned.
408 *
409 * @return Next work starting at current file position or null if end of
410 * stream is reached.
411 * @throws IOException if an I/O error occurs.
412 */
413 public String readWord() throws IOException {
414 // reads until space, line feed, carriage return or tab is found
415 if (isEndOfStream()) {
416 return null;
417 } else {
418 return readUntilAnyOfTheseCharactersIsFound(" \r\n\t");
419 }
420 }
421
422 /**
423 * Sequentially reads characters starting at current file position until one
424 * of the characters in provided pattern is found.
425 * All characters read so far will be returned without including any of the
426 * pattern characters.
427 *
428 * @param pattern Stop characters to stop reading when they are found.
429 * @return String read so far until any of the pattern characters was found.
430 * @throws IOException if an I/O error occurs.
431 * @throws IllegalArgumentException if no pattern characters are provided.
432 */
433 public abstract String readUntilAnyOfTheseCharactersIsFound(final String pattern)
434 throws IOException;
435
436 /**
437 * Writes a boolean to the file as a one-byte value. The value true is
438 * written out as the value (byte)1; the value false is written out as the
439 * value (byte)0. The write starts at the current position of the file
440 * pointer.
441 *
442 * @param v a boolean value to be written.
443 * @throws IOException if an I/O error occurs.
444 */
445 public abstract void writeBoolean(final boolean v) throws IOException;
446
447 /**
448 * Writes a byte to the file as a one-byte value. The write starts at the
449 * current position of the file pointer.
450 *
451 * @param v a byte value to be written.
452 * @throws IOException if an I/O error occurs.
453 */
454 public abstract void writeByte(final byte v) throws IOException;
455
456 /**
457 * Writes provided value in the range 0-255 as an unsigned byte. The write
458 * starts at the current position of the file pointer.
459 *
460 * @param v a value to be written as an unsigned byte.
461 * @throws IOException if an I/O error occurs.
462 */
463 public abstract void writeUnsignedByte(final short v) throws IOException;
464
465 /**
466 * Writes a short to the file as two bytes, high byte first. The write
467 * starts at the current position of the file pointer.
468 *
469 * @param v a short to be written.
470 * @throws IOException if an I/O error occurs.
471 */
472 public abstract void writeShort(final short v) throws IOException;
473
474 /**
475 * Writes a short to the file as two bytes using provided endian type.
476 * If endian type is big endian, then natural byte order is preserved (and
477 * high byte is written first), if little endian order is chosen, then byte
478 * order is reversed.
479 *
480 * @param v a short to be written.
481 * @param endianType endian type. If it is big endian, natural byte order is
482 * preserved, otherwise byte order is reversed.
483 * @throws IOException if an I/O error occurs.
484 */
485 public abstract void writeShort(final short v, final EndianType endianType)
486 throws IOException;
487
488 /**
489 * Writes an unsigned short to the file as two bytes, high byte first.
490 * Provided integer value is converted to an unsigned short by taking into
491 * account only the two lower bytes. The write starts at the current
492 * position of the file pointer.
493 *
494 * @param v an unsigned short to be written (int is converted to unsigned
495 * short).
496 * @throws IOException if an I/O error occurs.
497 */
498 public abstract void writeUnsignedShort(final int v) throws IOException;
499
500 /**
501 * Writes an unsigned short to the file as two bytes, using provided endian
502 * type.
503 * Provided integer value is converted to an unsigned short by taking into
504 * account only the two lower bytes.
505 * If endian type is big endian, then natural byte order is preserved (and
506 * high byte is written first), if little endian order is chosen, then byte
507 * order is reversed.
508 * The write starts at the current position of the file pointer.
509 *
510 * @param v an unsigned short to be written (int is converted to unsigned
511 * short).
512 * @param endianType endian type. If it is big endian, natural byte order is
513 * preserved, otherwise byte order is reversed.
514 * @throws IOException if an I/O error occurs.
515 */
516 public abstract void writeUnsignedShort(final int v, final EndianType endianType)
517 throws IOException;
518
519 /**
520 * Writes an int to the file as four bytes, high byte first. The write
521 * starts at the current position of the file pointer.
522 *
523 * @param v an int to be written.
524 * @throws IOException if an I/O error occurs.
525 */
526 public abstract void writeInt(final int v) throws IOException;
527
528 /**
529 * Writes an int to the file as four bytes, using provided endian type.
530 * If endian type is big endian, then natural byte order is preserved (and
531 * high byte is written first), if little endian order is chosen, then byte
532 * order is reversed.
533 * The write starts at the current position of the file pointer.
534 *
535 * @param v an int to be written.
536 * @param endianType endian type. If it is big endian, natural byte order is
537 * preserved, otherwise byte order is reversed.
538 * @throws IOException if an I/O error occurs.
539 */
540 public abstract void writeInt(final int v, final EndianType endianType)
541 throws IOException;
542
543 /**
544 * Writes an unsigned int to the file as four bytes, high byte first.
545 * Provided integer value is converted to an unsigned int by taking into
546 * account only the four lower bytes. The write starts at the current
547 * position of the file pointer.
548 *
549 * @param v an unsigned int to be written (long is converted to unsigned
550 * int).
551 * @throws IOException if an I/O error occurs.
552 */
553 public abstract void writeUnsignedInt(final long v) throws IOException;
554
555 /**
556 * Writes an unsigned int to the file as four bytes, using provided endian
557 * type.
558 * Provided integer value is converted to an unsigned int by taking into
559 * account only the four lower bytes.
560 * If endian type is big endian, then natural byte order is preserved (and
561 * high byte is written first), if little endian order is chosen, then byte
562 * order is reversed.
563 * The write starts at the current position of the file pointer.
564 *
565 * @param v an unsigned int to be written (long is converted to unsigned
566 * short).
567 * @param endianType endian type. If it is big endian, natural byte order is
568 * preserved, otherwise byte order is reversed.
569 * @throws IOException if an I/O error occurs.
570 */
571 public abstract void writeUnsignedInt(final long v, final EndianType endianType)
572 throws IOException;
573
574 /**
575 * Writes a long to the file as eight bytes, high byte first. The write
576 * starts at the current position of the file pointer.
577 *
578 * @param v a long to be written.
579 * @throws IOException if an I/O error occurs.
580 */
581 public abstract void writeLong(final long v) throws IOException;
582
583 /**
584 * Writes a long to the file as eight bytes, using provided endian type.
585 * If endian type is big endian, then natural byte order is preserved (and
586 * high byte is written first), if little endian order is chosen, then byte
587 * order is reversed.
588 * The write starts at the current position of the file pointer.
589 *
590 * @param v a long to be written.
591 * @param endianType endian type. If it is big endian, natural byte order is
592 * preserved, otherwise byte order is reversed.
593 * @throws IOException if an I/O error occurs.
594 */
595 public abstract void writeLong(final long v, final EndianType endianType)
596 throws IOException;
597
598 /**
599 * Converts the float argument to an int using the floatToIntBits method in
600 * class Float, and then write that int value to the file as a four-byte
601 * quantity, high byte first. The write starts at the current position of
602 * the file pointer.
603 *
604 * @param v a float value to be written.
605 * @throws IOException if an I/O error occurs.
606 */
607 public abstract void writeFloat(final float v) throws IOException;
608
609 /**
610 * Converts the float argument to an int using the floatToIntBits method in
611 * class Float, and then write that int value to the file as a four-byte
612 * quantity, using provided endian type.
613 * If endian type is big endian, then natural byte order is preserved (and
614 * high byte is written first), if little endian order is chosen, then byte
615 * order is reversed.
616 * The write starts at the current position of the file pointer.
617 *
618 * @param v a float value to be written.
619 * @param endianType endian type. If it is big endian, natural byte order is
620 * preserved, otherwise byte order is reversed.
621 * @throws IOException if an I/O error occurs.
622 */
623 public abstract void writeFloat(final float v, final EndianType endianType)
624 throws IOException;
625
626 /**
627 * Converts the double argument to a long using the doubleToLongBits method
628 * in class Double, and then writes that long value to the file as an eight
629 * byte quantity, high byte first. The write starts at the current position
630 * of the file pointer.
631 *
632 * @param v a double value to be written.
633 * @throws IOException if an I/O error occurs.
634 */
635 public abstract void writeDouble(final double v) throws IOException;
636
637 /**
638 * Converts the double argument to a long using the doubleToLongBits method
639 * in class Double, and then writes that long value to the file as an eight
640 * byte quantity, using provided endian type.
641 * If endian type is big endian, then natural byte order is preserved (and
642 * high byte is written first), if little endian order is chosen, then byte
643 * order is reversed.
644 * The write starts at the current position of the file pointer.
645 *
646 * @param v a double value to be written.
647 * @param endianType endian type. If it is big endian, natural byte order is
648 * preserved, otherwise byte order is reversed.
649 * @throws IOException if an I/O error occurs.
650 */
651 public abstract void writeDouble(final double v, final EndianType endianType)
652 throws IOException;
653
654 /**
655 * Writes the string to the file as a sequence of bytes. Each character in
656 * the string is written out, in sequence, by discarding its high eight
657 * bits. The write starts at the current position of the file pointer.
658 *
659 * @param s a string of bytes to be written.
660 * @throws IOException if an I/O error occurs.
661 */
662 public abstract void writeASCII(final String s) throws IOException;
663 }