From be952acbcbeadf041c73d19a6ecac7ac72d21ac2 Mon Sep 17 00:00:00 2001 From: Pierre Carrier Date: Sun, 4 Nov 2012 01:56:06 +0100 Subject: [PATCH] classpath: Closeable & Flushable --- classpath/java/io/Closeable.java | 16 ++++++++++++++++ classpath/java/io/Flushable.java | 16 ++++++++++++++++ classpath/java/io/InputStream.java | 2 +- classpath/java/io/OutputStream.java | 2 +- classpath/java/io/Reader.java | 2 +- classpath/java/io/Writer.java | 2 +- 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 classpath/java/io/Closeable.java create mode 100644 classpath/java/io/Flushable.java diff --git a/classpath/java/io/Closeable.java b/classpath/java/io/Closeable.java new file mode 100644 index 0000000000..e24a572fb5 --- /dev/null +++ b/classpath/java/io/Closeable.java @@ -0,0 +1,16 @@ +/* Copyright (c) 2012, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.io; + +public interface Closeable { + void close() + throws IOException; +} diff --git a/classpath/java/io/Flushable.java b/classpath/java/io/Flushable.java new file mode 100644 index 0000000000..25b941d4bb --- /dev/null +++ b/classpath/java/io/Flushable.java @@ -0,0 +1,16 @@ +/* Copyright (c) 2012, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +package java.io; + +public interface Flushable { + void flush() + throws IOException; +} diff --git a/classpath/java/io/InputStream.java b/classpath/java/io/InputStream.java index ec29b52b7a..d6ab46c140 100644 --- a/classpath/java/io/InputStream.java +++ b/classpath/java/io/InputStream.java @@ -10,7 +10,7 @@ package java.io; -public abstract class InputStream { +public abstract class InputStream implements Closeable { public abstract int read() throws IOException; public int read(byte[] buffer) throws IOException { diff --git a/classpath/java/io/OutputStream.java b/classpath/java/io/OutputStream.java index caeccde12c..b73345ee16 100644 --- a/classpath/java/io/OutputStream.java +++ b/classpath/java/io/OutputStream.java @@ -10,7 +10,7 @@ package java.io; -public abstract class OutputStream { +public abstract class OutputStream implements Closeable, Flushable { public abstract void write(int c) throws IOException; public void write(byte[] buffer) throws IOException { diff --git a/classpath/java/io/Reader.java b/classpath/java/io/Reader.java index 2edfd70803..668f82b1cf 100644 --- a/classpath/java/io/Reader.java +++ b/classpath/java/io/Reader.java @@ -10,7 +10,7 @@ package java.io; -public abstract class Reader { +public abstract class Reader implements Closeable { public int read() throws IOException { char[] buffer = new char[1]; int c = read(buffer); diff --git a/classpath/java/io/Writer.java b/classpath/java/io/Writer.java index 0d5b8fbf85..2ea1bcba07 100644 --- a/classpath/java/io/Writer.java +++ b/classpath/java/io/Writer.java @@ -10,7 +10,7 @@ package java.io; -public abstract class Writer { +public abstract class Writer implements Closeable, Flushable { public void write(int c) throws IOException { char[] buffer = new char[] { (char) c }; write(buffer);