Java file I/O lab exercises for the Object-Oriented Computing 2 (OOC2) module. These examples demonstrate reading from and writing to files using byte streams, character streams, and buffered I/O.
This repository contains a collection of Java programs that illustrate core file I/O concepts from the java.io package. Each class focuses on a different aspect of file handling, from low-level byte-at-a-time copying to buffered readers, Scanner-based parsing, and formatted output. Sample resource files are included so that every example can be compiled and run immediately.
- Byte stream copying with
FileInputStreamandFileOutputStream, including ASCII visualization - Character stream copying using
FileReaderandFileWriter - Buffered I/O with
BufferedReaderfor efficient line-by-line reading - Scanner-based file parsing to read integers and compute averages from a file
- Formatted file output using
java.util.Formatter - Exception handling patterns with try-catch-finally for resource management
- Sample resource files including text files, CSV data, and serialized objects
- Java Development Kit (JDK) 8 or later
- A Java IDE (Eclipse, IntelliJ IDEA, or VS Code) or the command-line
javaccompiler
git clone https://github.com/danielcregg/ooc2-io.git
cd ooc2-ioCompile and run any example from the project root:
javac -d bin src/ie/gmit/ooc2labs/io/CopyFileByte.java
java -cp bin ie.gmit.ooc2labs.io.CopyFileByteThe programs read from and write to the resources/ directory, which contains all required input files.
| Technology | Purpose |
|---|---|
| Java 8 | Core programming language and I/O APIs |
| java.io | File streams, readers, writers, and buffered I/O |
| java.util.Scanner | File parsing and tokenization |
This project is licensed under the MIT License. See the LICENSE file for details.