background preloader

Embeded DB (& file handling)

Facebook Twitter

Java: File I/O - Text Files. Java can read several types of information from files: binary, Java objects, text, zipped files, etc.

Java: File I/O - Text Files

One of the most common problems is reading lines of text. Example: Copy one file to another This example reads text files using the classes FileReader, BufferedReader, FileWriter, and BufferedWriter. It's a main program without a graphical user interface, reading from the console. Reading and writing text files. In JDK 7, the most important classes for text files are: Paths and Path - file locations/names, but not their content.

Reading and writing text files

Files - operations on file content. StandardCharsets and Charset (an older class), for encodings of text files. the File.toPath method, which lets older code interact nicely with the newer java.nio API. In addition, the following classes are also commonly used with text files, for both JDK 7 and earlier versions: Scanner - allows reading files in a compact wayBufferedReader - readLineBufferedWriter - write + newLine When reading and writing text files: it's often a good idea to use buffering (default size is 8K)there's always a need to pay attention to exceptions (in particular, IOException and FileNotFoundException)

BlockFile. A 100% Java 1.3, BSD Licensed, embeddable single file database engine in 32KB.

BlockFile

This database was designed for PDA based and J2ME applications. Table of Contents Features 100% Java 1.3. No JNI.