I/O : Java Glossary
©1996-2017 Roedy Green of Canadian Mind Products
Java has a bewildering array of I/O (input/output) routines. Many you can cascade
together like Lego blocks to create variants. Have a look at this essay on JDK 1.0.2 candidate
methods or this essay on Java version 1.1 candidate methods for the task at
hand. The Java version 1.6 or later essay also shows suggested
classes to use when upgrading deprecated JDK (Java Development Kit)
I have also written an amanuensis
Applet in Java, available with source code, to
automatically generate Java source code for various combinations of file type and
data type. You can just experiment to learn from complete examples, or you can cut
and paste the code into your own applications.
The File I/O Amanuensis generates sample Java source code to read or write the
console, a sequential file, a random access file, a String, an array of characters,
an array of bytes, URL (Uniform Resource Locator), HTTP (Hypertext Transfer Protocol)
CGI (Common Gateway Interface) GET/POST, Socket or Pipe. You can use them buffered,
unbuffered or GZIP compressed. Java works with seven types of data in your files:
Java is missing basic input routines. You have to roll your own with java.util.StringTokenizer,
java.io.StreamTokenizer or readLine to split the input up into strings, then use
various conversion methods to convert to float, int etc.
- 7 or 8-bit ASCII (American Standard Code for Information Interchange)
characters (plain or locale-encoded)
- UTF (Unicode Transformation unit) 8-bit Unicode compressed
- 16-bit Unicode characters
- Java binary format —
platform independent big-endian binary
representations. Have a look at this essay to see how DataOutputStream formats each of the
primitive data types.
- Little-endian binary format.
- raw bytes
- persistent serialised objects