harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [95/198] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core: ./ depends/ depends/files/ depends/jars/ depends/libs/ depends/libs/linux.IA32/ depends/libs/win.IA32/ depends/oss/ depends/oss/linux.IA32/ depends/oss/win.I...
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileDescriptor.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileDescriptor.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileDescriptor.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,88 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * FileDescriptor is the lowest level representation of a File, Device, or
+ * Socket. You can create any of the IO classes which take a FileDescriptor as
+ * an argument by querying an open Socket or File for the FileDescriptor.
+ * <p>
+ * The FileDescriptor class also contains static fields representing Standard
+ * Input, Output and Error. You can use these directly if desired but it is
+ * recommended you go through System.in, System.out, and System.err streams
+ * respectively.
+ * <p>
+ * Applications should not create new FileDescriptors.
+ * 
+ * @see FileInputStream#getFD()
+ * @see FileOutputStream#getFD()
+ * @see RandomAccessFile#getFD()
+ */
+public final class FileDescriptor {
+	/** FileDescriptor representing Standard In */
+	public static final FileDescriptor in = new FileDescriptor();
+
+	/** FileDescriptor representing Standard Out */
+	public static final FileDescriptor out = new FileDescriptor();
+
+	/** FileDescriptor representing Standard Error */
+	public static final FileDescriptor err = new FileDescriptor();
+
+	/**
+	 * Represents a link to any underlying OS resources for this FileDescriptor.
+	 * A value of -1 indicates that this FileDescriptor is invalid.
+	 */
+	long descriptor = -1;
+
+	private static native void oneTimeInitialization();
+
+	static {
+		in.descriptor = 0;
+		out.descriptor = 1;
+		err.descriptor = 2;
+
+		oneTimeInitialization();
+	}
+
+	/**
+	 * Constructs a new FileDescriptor containing an invalid handle. This
+	 * constructor does nothing interesting. Provided for signature
+	 * compatibility.
+	 * 
+	 */
+	public FileDescriptor() {
+		super();
+	}
+
+	/**
+	 * Ensures that data which is buffered within the underlying implementation
+	 * is written out to the appropriate device before returning.
+	 * 
+	 * @throws SyncFailedException
+	 *             when the operation fails
+	 */
+	public native void sync() throws SyncFailedException;
+
+	/**
+	 * Answers a boolean indicating whether or not this FileDescriptor is valid.
+	 * 
+	 * @return <code>true</code> if this FileDescriptor is valid,
+	 *         <code>false</code> otherwise
+	 */
+	public native boolean valid();
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileFilter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileFilter.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileFilter.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileFilter.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,32 @@
+/* Copyright 1998, 2002 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * FileFilter is an interface for filtering abstract Files
+ *
+ */
+public abstract interface FileFilter {
+
+/**
+ * Answers a boolean indicating whether or not a specific File should be included in a pathname list.
+ *
+ * @param		pathname	the abstract File to check.
+ * @return 		<code>true</code> if the File should be includes, <code>false</code> otherwise.
+ */
+public abstract boolean accept(File pathname);
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileInputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileInputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileInputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,266 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+import java.nio.channels.FileChannel;
+
+/**
+ * FileInputStream is a class for reading bytes from a file. This class may also
+ * be used with other InputStreams, ie: BufferedInputStream, to read data from a
+ * file with buffering.
+ * 
+ * @see FileOutputStream
+ */
+public class FileInputStream extends InputStream {
+	/**
+	 * The FileDescriptor representing this FileInputStream.
+	 */
+	FileDescriptor fd;
+
+	// The unique file channel associated with this FileInputStream (lazily
+	// initialized).
+	private FileChannel channel;
+
+	// Fill in the JNI id caches
+	private static native void oneTimeInitialization();
+
+	static {
+		oneTimeInitialization();
+	}
+
+	/**
+	 * Constructs a new FileInputStream on the File <code>file</code>. If the
+	 * file does not exist, the <code>FileNotFoundException</code> is thrown.
+	 * 
+	 * @param file
+	 *            the File on which to stream reads.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>file</code> is not found.
+	 * 
+	 * @see java.lang.SecurityManager#checkRead(FileDescriptor)
+	 * @see java.lang.SecurityManager#checkRead(String)
+	 * @see java.lang.SecurityManager#checkRead(String, Object)
+	 */
+	public FileInputStream(File file) throws FileNotFoundException {
+		super();
+		SecurityManager security = System.getSecurityManager();
+		if (security != null)
+			security.checkRead(file.getPath());
+		fd = new FileDescriptor();
+		if (openImpl(file.properPath(true)) != 0)
+			throw new FileNotFoundException(file.getPath());
+	}
+
+	/**
+	 * Constructs a new FileInputStream on the FileDescriptor <code>fd</code>.
+	 * The file must already be open, therefore no
+	 * <code>FileNotFoundException</code> will be thrown.
+	 * 
+	 * @param fd
+	 *            the FileDescriptor on which to stream reads.
+	 * 
+	 * @see java.lang.SecurityManager#checkRead(FileDescriptor)
+	 * @see java.lang.SecurityManager#checkRead(String)
+	 * @see java.lang.SecurityManager#checkRead(String, Object)
+	 */
+	public FileInputStream(FileDescriptor fd) {
+		super();
+		if (fd != null) {
+			SecurityManager security = System.getSecurityManager();
+			if (security != null)
+				security.checkRead(fd);
+			this.fd = fd;
+		} else
+			throw new NullPointerException();
+	}
+
+	/**
+	 * Constructs a new FileInputStream on the file named <code>fileName</code>.
+	 * If the file does not exist, the <code>FileNotFoundException</code> is
+	 * thrown. The <code>fileName</code> may be absolute or relative to the
+	 * System property <code>"user.dir"</code>.
+	 * 
+	 * @param fileName
+	 *            the file on which to stream reads.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>fileName</code> is not found.
+	 */
+	public FileInputStream(String fileName) throws FileNotFoundException {
+		SecurityManager security = System.getSecurityManager();
+		if (security != null)
+			security.checkRead(fileName);
+		fd = new FileDescriptor();
+		if (openImpl(new File(fileName).properPath(true)) != 0)
+			throw new FileNotFoundException(fileName);
+	}
+
+	/**
+	 * Answers a int representing then number of bytes that are available before
+	 * this InputStream will block. This method always returns the size of the
+	 * file minus the current position.
+	 * 
+	 * @return the number of bytes available before blocking.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs in this stream.
+	 */
+	public native int available() throws IOException;
+
+	/**
+	 * Close the FileInputStream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this FileInputStream.
+	 */
+	public void close() throws IOException {
+		closeImpl();
+	}
+
+	private native void closeImpl() throws IOException;
+
+	/**
+	 * This method ensures that all resources for this file are released when it
+	 * is about to be garbage collected.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to finalize this
+	 *             FileInputStream.
+	 */
+	protected void finalize() throws IOException {
+		if (this.fd != null)
+			close();
+	}
+
+	/**
+	 * Answers the FileChannel equivalent to this input stream.
+	 * <p>
+	 * The file channel is read-only and has an initial position within the file
+	 * that is the same as the current position of the FileInputStream within
+	 * the file. All changes made to the underlying file descriptor state via
+	 * the channel are visible by the input stream and vice versa.
+	 * </p>
+	 * 
+	 * @return the file channel representation for this FileInputStream.
+	 */
+	public synchronized FileChannel getChannel() {
+		if (channel == null) {
+			channel = FileChannelFactory.getFileChannel(fd.descriptor,
+					FileChannelFactory.O_RDONLY);
+		}
+		return channel;
+	}
+
+	/**
+	 * Answers the FileDescriptor representing the operating system resource for
+	 * this FileInputStream.
+	 * 
+	 * @return the FileDescriptor for this FileInputStream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to get the FileDescriptor of
+	 *             this FileInputStream.
+	 */
+	public final FileDescriptor getFD() throws IOException {
+		if (fd != null)
+			return fd;
+		throw new IOException();
+	}
+
+	private native int openImpl(byte[] fileName);
+
+	/**
+	 * Reads a single byte from this FileInputStream and returns the result as
+	 * an int. The low-order byte is returned or -1 of the end of stream was
+	 * encountered.
+	 * 
+	 * @return the byte read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read() throws IOException {
+		if (fd != null)
+			return readByteImpl(getFD().descriptor);
+		throw new IOException();
+	}
+
+	private native int readByteImpl(long descriptor) throws IOException;
+
+	/**
+	 * Reads bytes from the FileInputStream and stores them in byte array
+	 * <code>buffer</code>. Answer the number of bytes actually read or -1 if
+	 * no bytes were read and end of stream was encountered.
+	 * 
+	 * @param buffer
+	 *            the byte array in which to store the read bytes.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte[] buffer) throws IOException {
+		return read(buffer, 0, buffer.length);
+	}
+
+	/**
+	 * Reads at most <code>count</code> bytes from the FileInputStream and
+	 * stores them in byte array <code>buffer</code> starting at
+	 * <code>offset</code>. Answer the number of bytes actually read or -1 if
+	 * no bytes were read and end of stream was encountered.
+	 * 
+	 * @param buffer
+	 *            the byte array in which to store the read bytes.
+	 * @param offset
+	 *            the offset in <code>buffer</code> to store the read bytes.
+	 * @param count
+	 *            the maximum number of bytes to store in <code>buffer</code>.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte[] buffer, int offset, int count) throws IOException {
+		if (fd != null)
+			return readImpl(buffer, offset, count, getFD().descriptor);
+		throw new IOException();
+	}
+
+	private native int readImpl(byte[] buffer, int offset, int count,
+			long descriptor) throws IOException;
+
+	/**
+	 * Skips <code>count</code> number of bytes in this FileInputStream.
+	 * Subsequent <code>read()</code>'s will not return these bytes unless
+	 * <code>reset()</code> is used. This method may perform multiple reads to
+	 * read <code>count</code> bytes. This default implementation reads
+	 * <code>count</code> bytes into a temporary buffer.
+	 * 
+	 * @param count
+	 *            the number of bytes to skip.
+	 * @return the number of bytes actually skipped.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public native long skip(long count) throws IOException;
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileNotFoundException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileNotFoundException.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileNotFoundException.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileNotFoundException.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,44 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * This IO exception is thrown when a file specified by a program cannot be
+ * found.
+ * 
+ */
+public class FileNotFoundException extends IOException {
+
+	/**
+	 * Constructs a new instance of this class with its walkback filled in.
+	 */
+	public FileNotFoundException() {
+		super();
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            The detail message for the exception.
+	 */
+	public FileNotFoundException(String detailMessage) {
+		super(detailMessage);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileOutputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileOutputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileOutputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,295 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+import java.nio.channels.FileChannel;
+
+/**
+ * FileOutputStream is a class whose underlying stream is represented by a file
+ * in the operating system. The bytes that are written to this stream are passed
+ * directly to the underlying operating system equivalent function. Since
+ * overhead may be high in writing to the OS, FileOutputStreams are usually
+ * wrapped with a BufferedOutputStream to reduce the number of times the OS is
+ * called.
+ * <p>
+ * <code>BufferedOutputStream buf = new BufferedOutputStream(new FileOutputStream("aFile.txt"));</code>
+ * 
+ * @see FileInputStream
+ */
+public class FileOutputStream extends OutputStream {
+
+	/**
+	 * The FileDescriptor representing this FileOutputStream.
+	 */
+	FileDescriptor fd;
+
+	// The unique file channel associated with this FileInputStream (lazily
+	// initialized).
+	private FileChannel channel;
+
+	// Fill in the JNI id caches
+	private static native void oneTimeInitialization();
+
+	static {
+		oneTimeInitialization();
+	}
+
+	/**
+	 * Constructs a new FileOutputStream on the File <code>file</code>. If
+	 * the file exists, it is written over. See the constructor which can append
+	 * to the file if so desired.
+	 * 
+	 * @param file
+	 *            the File on which to stream reads.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>file</code> cannot be opened for writing.
+	 * 
+	 * @see java.lang.SecurityManager#checkWrite(FileDescriptor)
+	 */
+	public FileOutputStream(File file) throws FileNotFoundException {
+		this(file, false);
+	}
+
+	/**
+	 * Constructs a new FileOutputStream on the File <code>file</code>. If
+	 * the file exists, it is written over. The parameter <code>append</code>
+	 * determines whether or not the file is opened and appended to or just
+	 * opened empty.
+	 * 
+	 * @param file
+	 *            the File on which to stream reads.
+	 * @param append
+	 *            a boolean indicating whether or not to append to an existing
+	 *            file.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>file</code> cannot be opened for writing.
+	 * 
+	 * @see java.lang.SecurityManager#checkWrite(FileDescriptor)
+	 * @see java.lang.SecurityManager#checkWrite(String)
+	 */
+	public FileOutputStream(File file, boolean append)
+			throws FileNotFoundException {
+		super();
+		SecurityManager security = System.getSecurityManager();
+		if (security != null)
+			security.checkWrite(file.getPath());
+		fd = new FileDescriptor();
+		if (openImpl(file.properPath(true), append) != 0)
+			throw new FileNotFoundException(file.getPath());
+
+	}
+
+	/**
+	 * Constructs a new FileOutputStream on the FileDescriptor <code>fd</code>.
+	 * The file must already be open, therefore no <code>FileIOException</code>
+	 * will be thrown.
+	 * 
+	 * @param fd
+	 *            the FileDescriptor on which to stream writes.
+	 * 
+	 * @see java.lang.SecurityManager#checkWrite(FileDescriptor)
+	 */
+	public FileOutputStream(FileDescriptor fd) {
+		super();
+		if (fd != null) {
+			SecurityManager security = System.getSecurityManager();
+			if (security != null)
+				security.checkWrite(fd);
+			this.fd = fd;
+		} else
+			throw new NullPointerException(com.ibm.oti.util.Msg
+					.getString("K006c")); //$NON-NLS-1$
+	}
+
+	/**
+	 * Constructs a new FileOutputStream on the file named <code>fileName</code>.
+	 * If the file exists, it is written over. See the constructor which can
+	 * append to the file if so desired. The <code>fileName</code> may be
+	 * absolute or relative to the System property <code>"user.dir"</code>.
+	 * 
+	 * @param filename
+	 *            the file on which to stream writes.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>filename</code> cannot be opened for writing.
+	 */
+	public FileOutputStream(String filename) throws FileNotFoundException {
+		this(filename, false);
+	}
+
+	/**
+	 * Constructs a new FileOutputStream on the file named <code>filename</code>.
+	 * If the file exists, it is written over. The parameter <code>append</code>
+	 * determines whether or not the file is opened and appended to or just
+	 * opened empty. The <code>filename</code> may be absolute or relative to
+	 * the System property <code>"user.dir"</code>.
+	 * 
+	 * @param filename
+	 *            the file on which to stream writes.
+	 * @param append
+	 *            a boolean indicating whether or not to append to an existing
+	 *            file.
+	 * 
+	 * @throws FileNotFoundException
+	 *             If the <code>filename</code> cannot be opened for writing.
+	 */
+	public FileOutputStream(String filename, boolean append)
+			throws FileNotFoundException {
+		super();
+		SecurityManager security = System.getSecurityManager();
+		if (security != null)
+			security.checkWrite(filename);
+		fd = new FileDescriptor();
+		File f = new File(filename);
+		if (openImpl(f.properPath(true), append) != 0)
+			throw new FileNotFoundException(filename);
+
+	}
+
+	/**
+	 * Close the FileOutputStream. This implementation closes the underlying OS
+	 * resources allocated to represent this stream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this FileOutputStream.
+	 */
+	public void close() throws IOException {
+		closeImpl();
+	}
+
+	private native void closeImpl() throws IOException;
+
+	/**
+	 * Frees any resources allocated to represent this FileOutputStream before
+	 * it is garbage collected. This method is called from the Java Virtual
+	 * Machine.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to finalize this
+	 *             FileOutputStream.
+	 */
+	protected void finalize() throws IOException {
+		if (fd != null)
+			close();
+	}
+
+	/**
+	 * Answers the FileChannel equivalent to this output stream.
+	 * <p>
+	 * The file channel is write-only and has an initial position within the
+	 * file that is the same as the current position of this FileOutputStream
+	 * within the file. All changes made to the underlying file descriptor state
+	 * via the channel are visible by the output stream and vice versa.
+	 * </p>
+	 * 
+	 * @return the file channel representation for this FileOutputStream.
+	 */
+	public synchronized FileChannel getChannel() {
+		if (channel == null) {
+			channel = FileChannelFactory.getFileChannel(fd.descriptor,
+					FileChannelFactory.O_WRONLY);
+		}
+		return channel;
+	}
+
+	/**
+	 * Answers a FileDescriptor which represents the lowest level representation
+	 * of a OS stream resource.
+	 * 
+	 * @return a FileDescriptor representing this FileOutputStream.
+	 * 
+	 * @throws IOException
+	 *             If the Stream is already closed and there is no
+	 *             FileDescriptor.
+	 */
+	public final FileDescriptor getFD() throws IOException {
+		if (fd != null)
+			return fd;
+		throw new IOException();
+	}
+
+	private native int openImpl(byte[] fileName, boolean openAppend);
+
+	/**
+	 * Writes the entire contents of the byte array <code>buffer</code> to
+	 * this FileOutputStream.
+	 * 
+	 * @param buffer
+	 *            the buffer to be written
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FileOutputStream.
+	 */
+	public void write(byte[] buffer) throws IOException {
+		write(buffer, 0, buffer.length);
+	}
+
+	/**
+	 * Writes <code>count</code> <code>bytes</code> from the byte array
+	 * <code>buffer</code> starting at <code>offset</code> to this
+	 * FileOutputStream.
+	 * 
+	 * @param buffer
+	 *            the buffer to be written
+	 * @param offset
+	 *            offset in buffer to get bytes
+	 * @param count
+	 *            number of bytes in buffer to write
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FileOutputStream.
+	 * @throws IndexOutOfBoundsException
+	 *             If offset or count are outside of bounds.
+	 * @throws NullPointerException
+	 *             If buffer is <code>null</code>.
+	 */
+	public void write(byte[] buffer, int offset, int count) throws IOException {
+		if (fd == null)
+			throw new IOException();
+		writeImpl(buffer, offset, count, getFD().descriptor);
+	}
+
+	private native void writeImpl(byte[] buffer, int offset, int count,
+			long descriptor) throws IOException;
+
+	/**
+	 * Writes the specified byte <code>oneByte</code> to this
+	 * FileOutputStream. Only the low order byte of <code>oneByte</code> is
+	 * written.
+	 * 
+	 * @param oneByte
+	 *            the byte to be written
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FileOutputStream.
+	 */
+	public void write(int oneByte) throws IOException {
+		if (fd != null) {
+			writeByteImpl(oneByte, getFD().descriptor);
+		} else
+			throw new IOException();
+	}
+
+	private native void writeByteImpl(int oneByte, long descriptor)
+			throws IOException;
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermission.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermission.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermission.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermission.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,347 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PrivilegedAction;
+
+/**
+ * The class FilePermission is responsible for granting access to files or
+ * directories. The FilePermission is made up of a pathname and a set of actions
+ * which are valid for the pathname.
+ * <P>
+ * The <code>File.separatorChar</code> must be used in all pathnames when
+ * constructing a FilePermission. The following descriptions will assume the
+ * char is </code>/</code>. A pathname which ends in "/*", implies all the
+ * files and directories contained in that directory. If the pathname ends in
+ * "/-", it indicates all the files and directories in that directory
+ * <b>recursively</b>.
+ * 
+ */
+public final class FilePermission extends Permission implements Serializable {
+	static final long serialVersionUID = 7930732926638008763L;
+
+	// canonical path of this permission
+	private transient String canonPath;
+
+	// list of actions permitted for socket permission in order
+	private static final String[] actionList = { "read", "write", "execute", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			"delete" }; //$NON-NLS-1$
+
+	// "canonicalized" action list
+	private String actions;
+
+	// the numeric representation of this action list
+	// for implies() to check if one action list is the subset of another.
+	transient int mask = -1;
+
+	// global include all permission?
+	private transient boolean includeAll = false;
+
+	private transient boolean allDir = false;
+
+	private transient boolean allSubdir = false;
+
+	/**
+	 * Constructs a new FilePermission with the path and actions specified.
+	 * 
+	 * 
+	 * @param path
+	 *            the path to apply the actions to.
+	 * @param actions
+	 *            the actions for the <code>path<code>. May be any
+	 *							combination of read, write, execute, or delete.
+	 */
+	public FilePermission(String path, String actions) {
+		super(path);
+		init(path, actions);
+	}
+
+	private void init(final String path, String pathActions) {
+		if (pathActions != null && pathActions != "") { //$NON-NLS-1$
+			if (path != null) {
+				if (path.equals("<<ALL FILES>>")) { //$NON-NLS-1$
+					includeAll = true;
+				} else {
+					canonPath = (String) AccessController
+							.doPrivileged(new PrivilegedAction() {
+								public Object run() {
+									try {
+										return new File(path)
+												.getCanonicalPath();
+									} catch (IOException e) {
+										return path;
+									}
+								}
+							});
+					int plength = canonPath.length();
+					if (plength >= 1) {
+						if (canonPath.endsWith("*")) { //$NON-NLS-1$
+							if (plength == 1
+									|| (canonPath.charAt(plength - 2)) == File.separatorChar)
+								allDir = true;
+						} else if (canonPath.endsWith("-")) { //$NON-NLS-1$
+							if (plength == 1
+									|| (canonPath.charAt(plength - 2)) == File.separatorChar)
+								allSubdir = true;
+						}
+					}
+				}
+				this.actions = toCanonicalActionString(pathActions);
+			} else
+				throw new NullPointerException(com.ibm.oti.util.Msg
+						.getString("K006e")); //$NON-NLS-1$
+		} else
+			throw new IllegalArgumentException(com.ibm.oti.util.Msg
+					.getString("K006d")); //$NON-NLS-1$
+	}
+
+	/**
+	 * Answer the string representing this permissions actions. It must be of
+	 * the form "read,write,execute,delete", all lower case and in the correct
+	 * order if there is more than one action.
+	 * 
+	 * @param action
+	 *            the action name
+	 * @return the string representing this permission's actions
+	 */
+	private String toCanonicalActionString(String action) {
+		actions = action.trim().toLowerCase();
+
+		// get the numerical representation of the action list
+		mask = getMask(actions);
+
+		// convert the mask to a canonical action list.
+		int len = actionList.length;
+		// the test mask - shift the 1 to the leftmost position of the
+		// actionList
+		int highestBitMask = 1 << (len - 1);
+
+		// if a bit of mask is set, append the corresponding action to result
+		StringBuffer result = new StringBuffer();
+		boolean addedItem = false;
+		for (int i = 0; i < len; i++) {
+			if ((highestBitMask & mask) != 0) {
+				if (addedItem)
+					result.append(","); //$NON-NLS-1$
+				result.append(actionList[i]);
+				addedItem = true;
+			}
+			highestBitMask = highestBitMask >> 1;
+		}
+		return result.toString();
+	}
+
+	/**
+	 * Answers the numerical representation of the argument.
+	 * 
+	 * @param actionNames
+	 *            the action names
+	 * @return the action mask
+	 */
+	private int getMask(String actionNames) {
+		int actionInt = 0, head = 0, tail = 0;
+		do {
+			tail = actionNames.indexOf(",", head); //$NON-NLS-1$
+			String action = tail > 0 ? actionNames.substring(head, tail).trim()
+					: actionNames.substring(head).trim();
+			if (action.equals("read")) //$NON-NLS-1$
+				actionInt |= 8;
+			else if (action.equals("write")) //$NON-NLS-1$
+				actionInt |= 4;
+			else if (action.equals("execute")) //$NON-NLS-1$
+				actionInt |= 2;
+			else if (action.equals("delete")) //$NON-NLS-1$
+				actionInt |= 1;
+			else
+				throw new java.lang.IllegalArgumentException(
+						com.ibm.oti.util.Msg.getString("K006f", action)); //$NON-NLS-1$
+			head = tail + 1;
+		} while (tail > 0);
+		return actionInt;
+	}
+
+	/**
+	 * Answers the actions associated with the receiver.
+	 * 
+	 * @return the actions associated with the receiver.
+	 */
+	public String getActions() {
+		return actions;
+	}
+
+	/**
+	 * Check to see if this permission is equal to another. The two are equal if
+	 * <code>obj</code> is a FilePermission, they have the same path, and they
+	 * have the same actions.
+	 * 
+	 * @param obj
+	 *            the object to check equality with.
+	 * @return <code>true</code> if the two are equal, <code>false</code>
+	 *         otherwise.
+	 */
+	public boolean equals(Object obj) {
+		if (obj instanceof FilePermission) {
+			FilePermission fp = (FilePermission) obj;
+			if (fp.actions != actions)
+				if (fp.actions == null || !fp.actions.equals(actions))
+					return false;
+
+			/* Matching actions and both are <<ALL FILES>> ? */
+			if (fp.includeAll || includeAll)
+				return fp.includeAll == includeAll;
+			return fp.canonPath.equals(canonPath);
+		}
+		return false;
+	}
+
+	/**
+	 * Indicates whether the argument permission is implied by the receiver.
+	 * 
+	 * @param p
+	 *            java.security.Permission the permission to check.
+	 * @return <code>true</code> if the argument permission is implied by the
+	 *         receiver, and <code>false</code> if it is not.
+	 */
+	public boolean implies(Permission p) {
+		int match = impliesMask(p);
+		return match != 0 && match == ((FilePermission) p).mask;
+	}
+
+	/**
+	 * Answers an int describing what masks are implied by a specific
+	 * permission.
+	 * 
+	 * @param p
+	 *            the permission
+	 * @return the mask applied to the given permission
+	 */
+	int impliesMask(Permission p) {
+		if (!(p instanceof FilePermission))
+			return 0;
+		FilePermission fp = (FilePermission) p;
+		int matchedMask = mask & fp.mask;
+		// Can't match any bits?
+		if (matchedMask == 0)
+			return 0;
+
+		// Is this permission <<ALL FILES>>
+		if (includeAll)
+			return matchedMask;
+
+		// We can't imply all files
+		if (fp.includeAll)
+			return 0;
+
+		// Scan the length of p checking all match possibilities
+		// \- implies everything except \
+		int thisLength = canonPath.length();
+		if (allSubdir && thisLength == 2
+				&& !fp.canonPath.equals(File.separator))
+			return matchedMask;
+
+		boolean includeDir = false;
+		boolean lastIsSlash = false;
+		int pLength = fp.canonPath.length();
+		for (int i = 0; i < pLength; i++) {
+			char pChar = fp.canonPath.charAt(i);
+			// Is p longer than this permissions canonLength?
+			if (i >= thisLength) {
+				// If not includeDir then is has to be a mismatch.
+				if (!includeDir)
+					return 0;
+				/**
+				 * If we have * for this and the separator is not the last char
+				 * it is invalid. IE: this is '/a/*' and p is '/a/b/c' we should
+				 * fail on the separator after the b.
+				 */
+				if (pChar == File.separatorChar && (i != pLength - 1))
+					return 0;
+			} else {
+				// Can safely get cChar since it's in range.
+				char cChar = canonPath.charAt(i);
+				// Is this permission include all? (must have matched up until
+				// this point).
+				if (lastIsSlash && cChar == '-') {
+					// Checked at constructor for separator/-
+					if (!allSubdir)
+						return 0;
+					// If we've already seen '*' return 0, can't group - and *.
+					if (includeDir)
+						return 0;
+					return matchedMask;
+				}
+				// Is this permission include a dir? Continue the check
+				// afterwards.
+				if (lastIsSlash && cChar == '*') {
+					/* Checked at constructor for File.separator/* */
+					if (!allDir)
+						return 0;
+					// Cannot have two *'s in a row.
+					if (includeDir)
+						return 0;
+					// * does not match -
+					if (fp.allSubdir)
+						return 0;
+					// Set the fact that we have seen a * in this permission.
+					includeDir = true;
+					continue;
+				}
+				// Are the characters matched?
+				if (cChar != pChar)
+					return 0;
+				// Is is a separator char? Needed for /* and /-
+				lastIsSlash = cChar == File.separatorChar;
+			}
+		}
+		// Must have matched upto this point or it's a valid file in an include
+		// all directory
+		return pLength == thisLength || includeDir ? matchedMask : 0;
+	}
+
+	/**
+	 * Answers a new PermissionCollection in which to place FilePermission
+	 * Objects.
+	 * 
+	 * @return A new PermissionCollection suitable for storing FilePermission
+	 *         objects.
+	 */
+	public java.security.PermissionCollection newPermissionCollection() {
+		return new FilePermissionCollection();
+	}
+
+	/**
+	 * Answers an int representing the hash code value for this FilePermission.
+	 * 
+	 * @return int the hash code value for this FilePermission.
+	 */
+	public int hashCode() {
+		return (canonPath == null ? getName().hashCode() : canonPath.hashCode())
+				+ mask;
+	}
+
+	private void writeObject(ObjectOutputStream stream) throws IOException {
+		stream.defaultWriteObject();
+	}
+
+	private void readObject(ObjectInputStream stream) throws IOException,
+			ClassNotFoundException {
+		stream.defaultReadObject();
+		init(getName(), actions);
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermissionCollection.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermissionCollection.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermissionCollection.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilePermissionCollection.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,88 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+import java.security.Permission;
+import java.util.Vector;
+
+/**
+ * FilePermissionCollection is a class which holds a collection of
+ * FilePermission objects and can answer a boolean indicating whether or not a
+ * specific permissions is implied by a FilePermissionCollection.
+ * 
+ */
+final class FilePermissionCollection extends java.security.PermissionCollection
+		implements Serializable {
+	static final long serialVersionUID = 2202956749081564585L;
+
+	Vector permissions = new Vector();
+
+	/**
+	 * Construct a new FilePermissionCollection.
+	 */
+	public FilePermissionCollection() {
+		super();
+	}
+
+	/**
+	 * Add a permission Object to the permission collection.
+	 * 
+	 * @see java.security.PermissionCollection#add(java.security.Permission)
+	 */
+	public void add(Permission permission) {
+		if (!isReadOnly()) {
+			if (permission instanceof FilePermission)
+				permissions.addElement(permission);
+			else
+				throw new java.lang.IllegalArgumentException(permission
+						.toString());
+		} else
+			throw new IllegalStateException();
+	}
+
+	/**
+	 * Answers an enumeration for the collection of permissions.
+	 * 
+	 * @see java.security.PermissionCollection#elements()
+	 */
+	public java.util.Enumeration elements() {
+		return permissions.elements();
+	}
+
+	/**
+	 * Answers a boolean indicating whether or not this permissions collection
+	 * implies a specific <code>permission</code>.
+	 * 
+	 * @see java.security.PermissionCollection#implies(java.security.Permission)
+	 */
+	public boolean implies(Permission permission) {
+		if (permission instanceof FilePermission) {
+			FilePermission fp = (FilePermission) permission;
+			int matchedMask = 0;
+			int i = 0;
+			while (i < permissions.size()
+					&& ((matchedMask & fp.mask) != fp.mask)) {
+				// Cast will not fail since we added it
+				matchedMask |= ((FilePermission) permissions.elementAt(i))
+						.impliesMask(permission);
+				i++;
+			}
+			return ((matchedMask & fp.mask) == fp.mask);
+		}
+		return false;
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileReader.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileReader.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileReader.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,71 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * FileReader is class for turning a file into a character Stream. Data read
+ * from the source is converted into characters. The encoding is assumed to
+ * 8859_1. The FileReader contains a buffer of bytes read from the source and
+ * converts these into characters as needed. The buffer size is 8K.
+ * 
+ * @see FileWriter
+ */
+public class FileReader extends InputStreamReader {
+
+	/**
+	 * Construct a new FileReader on the given File <code>file</code>. If the
+	 * <code>file</code> specified cannot be found, throw a
+	 * FileNotFoundException.
+	 * 
+	 * @param file
+	 *            a File to be opened for reading characters from.
+	 * 
+	 * @throws FileNotFoundException
+	 *             if the file cannot be opened for reading.
+	 */
+	public FileReader(File file) throws FileNotFoundException {
+		super(new FileInputStream(file));
+	}
+
+	/**
+	 * Construct a new FileReader on the given FileDescriptor <code>fd</code>.
+	 * Since a previously opened FileDescriptor is passed as an argument, no
+	 * FileNotFoundException is thrown.
+	 * 
+	 * @param fd
+	 *            the previously opened file descriptor.
+	 */
+	public FileReader(FileDescriptor fd) {
+		super(new FileInputStream(fd));
+	}
+
+	/**
+	 * Construct a new FileReader on the given file named <code>filename</code>.
+	 * If the <code>filename</code> specified cannot be found, throw a
+	 * FileNotFoundException.
+	 * 
+	 * @param filename
+	 *            an absolute or relative path specifying the file to open.
+	 * 
+	 * @throws FileNotFoundException
+	 *             if the filename cannot be opened for reading.
+	 */
+	public FileReader(String filename) throws FileNotFoundException {
+		super(new FileInputStream(filename));
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileWriter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileWriter.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileWriter.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FileWriter.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,100 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * FileWriter is a class for writing characters out to a file. The default
+ * character encoding, 8859_1 is currently used to convert characters to bytes
+ * in the file.
+ * 
+ * @see FileReader
+ */
+public class FileWriter extends OutputStreamWriter {
+
+	/**
+	 * Creates a FileWriter using the File <code>file</code>.
+	 * 
+	 * @param file
+	 *            the non-null File to write bytes to.
+	 * 
+	 * @throws IOException
+	 *             If the given file is not found
+	 */
+	public FileWriter(File file) throws IOException {
+		super(new FileOutputStream(file));
+	}
+
+	/**
+	 * Creates a FileWriter using the File <code>file</code>. The parameter
+	 * <code>append</code> determines whether or not the file is opened and
+	 * appended to or just opened empty.
+	 * 
+	 * @param file
+	 *            the non-null File to write bytes to.
+	 * @param append
+	 *            should the file be appened to or opened empty.
+	 * 
+	 * @throws IOException
+	 *             If the given file is not found
+	 */
+	public FileWriter(File file, boolean append) throws IOException {
+		super(new FileOutputStream(file, append));
+	}
+
+	/**
+	 * Creates a FileWriter using the existing FileDescriptor <code>fd</code>.
+	 * 
+	 * @param fd
+	 *            the non-null FileDescriptor to write bytes to.
+	 */
+	public FileWriter(FileDescriptor fd) {
+		super(new FileOutputStream(fd));
+	}
+
+	/**
+	 * Creates a FileWriter using the platform dependent <code>filename</code>.
+	 * See the class description for how characters are converted to bytes.
+	 * 
+	 * @param filename
+	 *            the non-null name of the file to write bytes to.
+	 * 
+	 * @throws IOException
+	 *             If the given file is not found
+	 */
+	public FileWriter(String filename) throws IOException {
+		super(new FileOutputStream(new File(filename)));
+	}
+
+	/**
+	 * Creates a FileWriter using the platform dependent <code>filename</code>.
+	 * See the class description for how characters are converted to bytes. The
+	 * parameter <code>append</code> determines whether or not the file is
+	 * opened and appended to or just opened empty.
+	 * 
+	 * @param filename
+	 *            the non-null name of the file to write bytes to.
+	 * @param append
+	 *            should the file be appened to or opened empty.
+	 * 
+	 * @throws IOException
+	 *             If the given file is not found
+	 */
+	public FileWriter(String filename, boolean append) throws IOException {
+		super(new FileOutputStream(filename, append));
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilenameFilter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilenameFilter.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilenameFilter.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilenameFilter.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,38 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * FilenameFilter is an interface which declares methods for filtering file names
+ * in the <code>list</code> method of File.
+ *
+ * @see			File
+ * @see			File#list(FilenameFilter)
+ */
+public interface FilenameFilter {
+
+/**
+ * Answers a boolean if a specific filename matches a filter.
+ *
+ * @param		dir			the directory in which the <code>filename</code> was found.
+ * @param		filename	the name of the file in <code>dir</dir> to test.
+ * @return 		boolean		<code>true</code> if the filename matches the filter and can be included
+ *							in the list, <code>false</code> otherwise.
+ */
+public abstract boolean accept(File dir, String filename);
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterInputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterInputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterInputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,188 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * FilteredInputStream is a class which takes an input stream and
+ * <em>filters</em> the input in some way. The filtered view may be a buffered
+ * view or one which uncompresses data before returning bytes read.
+ * FilterInputStreams are meant for byte streams.
+ * 
+ * @see FilterOutputStream
+ */
+public class FilterInputStream extends InputStream {
+
+	/**
+	 * The target InputStream which is being filtered.
+	 */
+	protected InputStream in;
+
+	/**
+	 * Constructs a new FilterInputStream on the InputStream <code>in</code>.
+	 * All reads are now filtered through this stream.
+	 * 
+	 * @param in
+	 *            The non-null InputStream to filter reads on.
+	 */
+	protected FilterInputStream(InputStream in) {
+		super();
+		this.in = in;
+	}
+
+	/**
+	 * Answers a int representing the number of bytes that are available before
+	 * this FilterInputStream will block. This method returns the number of
+	 * bytes available in the target stream.
+	 * 
+	 * @return the number of bytes available before blocking.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs in this stream.
+	 */
+	public int available() throws IOException {
+		return in.available();
+	}
+
+	/**
+	 * Close this FilterInputStream. This implementation closes the target
+	 * stream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this stream.
+	 */
+	public void close() throws IOException {
+		in.close();
+	}
+
+	/**
+	 * Set a Mark position in this FilterInputStream. The parameter
+	 * <code>readLimit</code> indicates how many bytes can be read before a
+	 * mark is invalidated. Sending reset() will reposition the Stream back to
+	 * the marked position provided <code>readLimit</code> has not been
+	 * surpassed.
+	 * <p>
+	 * This implementation sets a mark in the target stream.
+	 * 
+	 * @param readlimit
+	 *            the number of bytes to be able to read before invalidating the
+	 *            mark.
+	 */
+	public synchronized void mark(int readlimit) {
+		in.mark(readlimit);
+	}
+
+	/**
+	 * Answers a boolean indicating whether or not this FilterInputStream
+	 * supports mark() and reset(). This implementation answers whether or not
+	 * the target stream supports marking.
+	 * 
+	 * @return <code>true</code> if mark() and reset() are supported,
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean markSupported() {
+		return in.markSupported();
+	}
+
+	/**
+	 * Reads a single byte from this FilterInputStream and returns the result as
+	 * an int. The low-order byte is returned or -1 of the end of stream was
+	 * encountered. This implementation returns a byte from the target stream.
+	 * 
+	 * @return the byte read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read() throws IOException {
+		return in.read();
+	}
+
+	/**
+	 * Reads bytes from this FilterInputStream and stores them in byte array
+	 * <code>buffer</code>. Answer the number of bytes actually read or -1 if
+	 * no bytes were read and end of stream was encountered. This implementation
+	 * reads bytes from the target stream.
+	 * 
+     * @param buffer
+	 *            the byte array in which to store the read bytes.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte[] buffer) throws IOException {
+		return read(buffer, 0, buffer.length);
+	}
+
+	/**
+	 * Reads at most <code>count</code> bytes from this FilterInputStream and
+	 * stores them in byte array <code>buffer</code> starting at
+	 * <code>offset</code>. Answer the number of bytes actually read or -1 if
+	 * no bytes were read and end of stream was encountered. This implementation
+	 * reads bytes from the target stream.
+	 * 
+	 * @param buffer
+	 *            the byte array in which to store the read bytes.
+	 * @param offset
+	 *            the offset in <code>buffer</code> to store the read bytes.
+	 * @param count
+	 *            the maximum number of bytes to store in <code>buffer</code>.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte[] buffer, int offset, int count) throws IOException {
+		return in.read(buffer, offset, count);
+	}
+
+	/**
+	 * Reset this FilterInputStream to the last marked location. If the
+	 * <code>readlimit</code> has been passed or no <code>mark</code> has
+	 * been set, throw IOException. This implementation resets the target
+	 * stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public synchronized void reset() throws IOException {
+		in.reset();
+	}
+
+	/**
+	 * Skips <code>count</code> number of bytes in this InputStream.
+	 * Subsequent <code>read()</code>'s will not return these bytes unless
+	 * <code>reset()</code> is used. This implementation skips
+	 * <code>count</code> number of bytes in the target stream.
+	 * 
+	 * @param count
+	 *            the number of bytes to skip.
+	 * @return the number of bytes actually skipped.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public long skip(long count) throws IOException {
+		return in.skip(count);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterOutputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterOutputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterOutputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterOutputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,137 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * FilteredOutputStream is a class which takes an output stream and
+ * <em>filters</em> the output in some way. The filtered view may be a
+ * buffered output or one which compresses data before actually writing the
+ * bytes. FilterOutputStreams are meant for byte streams.
+ * 
+ * @see FilterInputStream
+ */
+public class FilterOutputStream extends OutputStream {
+
+	/**
+	 * The target OutputStream for this filter.
+	 */
+	protected OutputStream out;
+
+	/**
+	 * Constructs a new FilterOutputStream on the OutputStream <code>out</code>.
+	 * All writes are now filtered through this stream.
+	 * 
+	 * @param out
+	 *            the target OutputStream to filter writes on.
+	 */
+	public FilterOutputStream(OutputStream out) {
+		this.out = out;
+	}
+
+	/**
+	 * Close this FilterOutputStream. This implementation closes the target
+	 * stream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this stream.
+	 */
+	public void close() throws IOException {
+		try {
+			flush();
+		} catch (IOException e) {
+		}
+		/* Make sure we clean up this stream if exception fires */
+		out.close();
+	}
+
+	/**
+	 * Flush this FilterOutputStream to ensure all pending data is sent out to
+	 * the target OutputStream. This implementation flushes the target
+	 * OutputStream.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to flush this
+	 *             FilterOutputStream.
+	 */
+	public void flush() throws IOException {
+		out.flush();
+	}
+
+	/**
+	 * Writes the entire contents of the byte array <code>buffer</code> to
+	 * this FilterOutputStream. This implementation writes the
+	 * <code>buffer</code> to the target stream.
+	 * 
+	 * @param buffer
+	 *            the buffer to be written
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FilterOutputStream.
+	 */
+	public void write(byte buffer[]) throws IOException {
+		write(buffer, 0, buffer.length);
+	}
+
+	/**
+	 * Writes <code>count</code> <code>bytes</code> from the byte array
+	 * <code>buffer</code> starting at <code>offset</code> to this
+	 * FilterOutputStream. This implementation writes the <code>buffer</code>
+	 * to the target OutputStream.
+	 * 
+	 * @param buffer
+	 *            the buffer to be written
+	 * @param offset
+	 *            offset in buffer to get bytes
+	 * @param count
+	 *            number of bytes in buffer to write
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FilterOutputStream.
+	 * @throws IndexOutOfBoundsException
+	 *             If offset or count are outside of bounds.
+	 */
+	public void write(byte buffer[], int offset, int count) throws IOException {
+		// avoid int overflow, check null buffer
+		if (offset <= buffer.length && 0 <= offset && 0 <= count
+				&& count <= buffer.length - offset) {
+			for (int i = 0; i < count; i++)
+				// Call write() instead of out.write() since subclasses could
+				// override the write() method.
+				write(buffer[offset + i]);
+		} else
+			throw new ArrayIndexOutOfBoundsException(com.ibm.oti.util.Msg
+					.getString("K002f")); //$NON-NLS-1$
+	}
+
+	/**
+	 * Writes the specified byte <code>oneByte</code> to this
+	 * FilterOutputStream. Only the low order byte of <code>oneByte</code> is
+	 * written. This implementation writes the byte to the target OutputStream.
+	 * 
+	 * @param oneByte
+	 *            the byte to be written
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to write to this
+	 *             FilterOutputStream.
+	 */
+	public void write(int oneByte) throws IOException {
+		out.write(oneByte);
+	}
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterReader.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterReader.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterReader.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,192 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * FilterReader is a class which takes a Reader and <em>filters</em> the input
+ * in some way. The filtered view may be a buffered view or one which
+ * uncompresses data before returning characters read.
+ * 
+ * @see FilterWriter
+ */
+public abstract class FilterReader extends Reader {
+
+	/**
+	 * The target Reader which is being filtered.
+	 */
+	protected Reader in;
+
+	/**
+	 * Constructs a new FilterReader on the Reader <code>in</code>. All reads
+	 * are now filtered through this Reader.
+	 * 
+	 * @param in
+	 *            The non-null Reader to filter reads on.
+	 */
+	protected FilterReader(Reader in) {
+		super(in);
+		this.in = in;
+	}
+
+	/**
+	 * Close this FilterReader. This implementation closes the target Reader.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this Reader.
+	 */
+	public void close() throws IOException {
+		synchronized (lock) {
+			in.close();
+		}
+	}
+
+	/**
+	 * Set a Mark position in this FilterReader. The parameter
+	 * <code>readLimit</code> indicates how many characters can be read before
+	 * a mark is invalidated. Sending reset() will reposition the Reader back to
+	 * the marked position provided <code>readLimit</code> has not been
+	 * surpassed.
+	 * <p>
+	 * This implementation sets a mark in the target Reader.
+	 * 
+	 * @param readlimit
+	 *            the number of characters to be able to read before
+	 *            invalidating the mark.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting mark this Reader.
+	 */
+	public synchronized void mark(int readlimit) throws IOException {
+		synchronized (lock) {
+			in.mark(readlimit);
+		}
+	}
+
+	/**
+	 * Answers a boolean indicating whether or not this FilterReader supports
+	 * mark() and reset(). This implementation answers whether or not the target
+	 * Reader supports marking.
+	 * 
+	 * @return indicates whether or not mark() and reset() are supported.
+	 */
+	public boolean markSupported() {
+		synchronized (lock) {
+			return in.markSupported();
+		}
+	}
+
+	/**
+	 * Reads a single char from this FilterReader and returns the result as an
+	 * int. The 2 lowest order bytes are returned or -1 of the end of reader was
+	 * encountered. This implementation returns a char from the target Reader.
+	 * 
+	 * @return The byte read or -1 if end of reader.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to read from this Reader.
+	 */
+	public int read() throws IOException {
+		synchronized (lock) {
+			return in.read();
+		}
+	}
+
+	/**
+	 * Reads at most <code>count</code> chars from this FilterReader and
+	 * stores them in char array <code>buffer</code> starting at offset
+	 * <code>offset</code>. Answer the number of chars actually read or -1 if
+	 * no chars were read and end of reader was encountered. This implementation
+	 * reads chars from the target reader.
+	 * 
+	 * @param buffer
+	 *            the char array in which to store the read chars.
+	 * @param offset
+	 *            the offset in <code>buffer</code> to store the read chars.
+	 * @param count
+	 *            the maximum number of chars to store in <code>buffer</code>.
+	 * @return the number of chars actually read or -1 if end of reader.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to read from this Reader.
+	 */
+	public int read(char[] buffer, int offset, int count) throws IOException {
+		synchronized (lock) {
+			return in.read(buffer, offset, count);
+		}
+	}
+
+	/**
+	 * Answers a <code>boolean</code> indicating whether or not this Reader is
+	 * ready to be read without blocking. If the result is <code>true</code>,
+	 * the next <code>read()</code> will not block. If the result is
+	 * <code>false</code> this Reader may or may not block when
+	 * <code>read()</code> is sent.
+	 * 
+	 * @return <code>true</code> if the receiver will not block when
+	 *         <code>read()</code> is called, <code>false</code> if unknown
+	 *         or blocking will occur.
+	 * 
+	 * @throws IOException
+	 *             If the Reader is already closed or some other IO error
+	 *             occurs.
+	 */
+
+	public boolean ready() throws IOException {
+		synchronized (lock) {
+			return in.ready();
+		}
+	}
+
+	/**
+	 * Reset this Readers position to the last <code>mark()</code> location.
+	 * Invocations of <code>read()/skip()</code> will occur from this new
+	 * location. If this Reader was not marked, the implementation of
+	 * <code>reset()</code> is implementation specific. See the comment for
+	 * the specific Reader subclass for implementation details. The default
+	 * action is to throw <code>IOException</code>.
+	 * 
+	 * @throws IOException
+	 *             if a problem occured or the target Reader does not support
+	 *             <code>mark()/reset()</code>.
+	 */
+	public void reset() throws IOException {
+		synchronized (lock) {
+			in.reset();
+		}
+	}
+
+	/**
+	 * Skips <code>count</code> number of characters in this Reader.
+	 * Subsequent <code>read()</code>'s will not return these characters
+	 * unless <code>reset()</code> is used. The default implementation is to
+	 * skip chars in the filtered Reader.
+	 * 
+	 * @param count
+	 *            the maximum number of characters to skip.
+	 * @return the number of characters actually skipped.
+	 * 
+	 * @throws IOException
+	 *             If the Reader is already closed or some other IO error
+	 *             occurs.
+	 */
+	public long skip(long count) throws IOException {
+		synchronized (lock) {
+			return in.skip(count);
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterWriter.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterWriter.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterWriter.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/FilterWriter.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,134 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * FilterWriter is a class which takes a Writer and <em>filters</em> the
+ * output in some way. The filtered view may be a buffered output or one which
+ * compresses data before actually writing the bytes.
+ * 
+ * @see FilterWriter
+ */
+public abstract class FilterWriter extends Writer {
+
+	/**
+	 * The Writer being filtered.
+	 */
+	protected Writer out;
+
+	/**
+	 * Constructs a new FilterWriter on the Writer <code>out</code>. All
+	 * writes are now filtered through this Writer.
+	 * 
+	 * @param out
+	 *            the target Writer to filter writes on.
+	 */
+	protected FilterWriter(Writer out) {
+		super(out);
+		this.out = out;
+	}
+
+	/**
+	 * Close this FilterWriter. Closes the Writer <code>out</code> by default.
+	 * This will close any downstream Writers as well. Any additional processing
+	 * required by concrete subclasses should be provided in their own
+	 * <code>close</code> implementation.
+	 * 
+	 * @throws java.io.IOException
+	 *             If an error occurs attempting to close this FilterWriter.
+	 */
+	public void close() throws IOException {
+		synchronized (lock) {
+			out.close();
+		}
+	}
+
+	/**
+	 * Flush this FilteredWriter to ensure all pending data is sent out to the
+	 * target Writer. This implementation flushes the target Writer.
+	 * 
+	 * @throws java.io.IOException
+	 *             If an error occurs attempting to flush this FilterWriter.
+	 */
+	public void flush() throws IOException {
+		synchronized (lock) {
+			out.flush();
+		}
+	}
+
+	/**
+	 * Writes <code>count</code> <code>chars</code> from the char array
+	 * <code>buffer</code> starting at offset <code>index</code> to this
+	 * FilterWriter. This implementation writes the <code>buffer</code> to the
+	 * target Writer.
+	 * 
+	 * @param buffer
+	 *            the buffer to be written
+	 * @param offset
+	 *            offset in buffer to get chars
+	 * @param count
+	 *            number of chars in buffer to write
+	 * 
+	 * @throws java.io.IOException
+	 *             If an error occurs attempting to write to this FilterWriter.
+	 */
+	public void write(char buffer[], int offset, int count) throws IOException {
+		synchronized (lock) {
+			out.write(buffer, offset, count);
+		}
+	}
+
+	/**
+	 * Writes the specified char <code>oneChar</code> to this FilterWriter.
+	 * Only the 2 low order bytes of <code>oneChar</code> is written. This
+	 * implementation writes the char to the target Writer.
+	 * 
+	 * @param oneChar
+	 *            the char to be written
+	 * 
+	 * @throws java.io.IOException
+	 *             If an error occurs attempting to write to this FilterWriter.
+	 */
+	public void write(int oneChar) throws IOException {
+		synchronized (lock) {
+			out.write(oneChar);
+		}
+	}
+
+	/**
+	 * Writes <code>count</code> <code>chars</code> from the String
+	 * <code>str</code> starting at offset <code>index</code> to this
+	 * FilterWriter. This implementation writes the <code>str</code> to the
+	 * target Writer.
+	 * 
+	 * @param str
+	 *            the String to be written.
+	 * @param offset
+	 *            offset in str to get chars.
+	 * @param count
+	 *            number of chars in str to write.
+	 * 
+	 * @throws java.io.IOException
+	 *             If an error occurs attempting to write to this FilterWriter.
+	 */
+	public void write(String str, int offset, int count) throws IOException {
+		synchronized (lock) {
+			out.write(str, offset, count);
+		}
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/IOException.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/IOException.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/IOException.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/IOException.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,45 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io;
+
+
+/**
+ * This IO exception is thrown when a program encounters some sort I/O error.
+ * Details may be specified in the constructor or by one of the subclasses.
+ * 
+
+ */
+public class IOException extends Exception {
+
+	/**
+	 * Constructs a new instance of this class with its walkback filled in.
+	 */
+	public IOException() {
+		super();
+	}
+
+	/**
+	 * Constructs a new instance of this class with its walkback and message
+	 * filled in.
+	 * 
+	 * @param detailMessage
+	 *            The detail message for the exception.
+	 */
+	public IOException(String detailMessage) {
+		super(detailMessage);
+	}
+
+}

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/InputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/InputStream.java?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/InputStream.java (added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/java-src/luni/src/java/io/InputStream.java Wed Nov 30 21:29:27 2005
@@ -0,0 +1,211 @@
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.io; 
+
+
+/**
+ * InputStream is an abstract class for all byte input streams. It provides
+ * basic method implementations for reading bytes from a stream.
+ * 
+ * @see OutputStream
+ */
+public abstract class InputStream extends Object {
+
+	private static byte[] skipBuf;
+
+	/**
+	 * This constructor does nothing interesting. Provided for signature
+	 * compatibility.
+	 */
+	public InputStream() {
+		/* empty */
+	}
+
+	/**
+	 * Answers a int representing then number of bytes that are available before
+	 * this InputStream will block. This method always returns 0. Subclasses
+	 * should override and indicate the correct number of bytes available.
+	 * 
+	 * @return the number of bytes available before blocking.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs in this InputStream.
+	 */
+	public int available() throws IOException {
+		return 0;
+	}
+
+	/**
+	 * Close the InputStream. Concrete implementations of this class should free
+	 * any resources during close. This implementation does nothing.
+	 * 
+	 * @throws IOException
+	 *             If an error occurs attempting to close this InputStream.
+	 */
+	public void close() throws IOException {
+		/* empty */
+	}
+
+	/**
+	 * Set a Mark position in this InputStream. The parameter
+	 * <code>readLimit</code> indicates how many bytes can be read before a
+	 * mark is invalidated. Sending reset() will reposition the Stream back to
+	 * the marked position provided <code>readLimit</code> has not been
+	 * surpassed.
+	 * <p>
+	 * This default implementation does nothing and concrete subclasses must
+	 * provide their own implementations.
+	 * 
+	 * @param readlimit
+	 *            the number of bytes to be able to read before invalidating the
+	 *            mark.
+	 */
+	public void mark(int readlimit) {
+		/* empty */
+	}
+
+	/**
+	 * Answers a boolean indicating whether or not this InputStream supports
+	 * mark() and reset(). This class provides a default implementation which
+	 * answers false.
+	 * 
+	 * @return <code>true</code> if mark() and reset() are supported,
+	 *         <code>false</code> otherwise.
+	 */
+	public boolean markSupported() {
+		return false;
+	}
+
+	/**
+	 * Reads a single byte from this InputStream and returns the result as an
+	 * int. The low-order byte is returned or -1 of the end of stream was
+	 * encountered. This abstract implementation must be provided by concrete
+	 * subclasses.
+	 * 
+	 * @return the byte read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public abstract int read() throws IOException;
+
+	/**
+	 * Reads bytes from the Stream and stores them in byte array <code>b</code>.
+	 * Answer the number of bytes actually read or -1 if no bytes were read and
+	 * end of stream was encountered.
+	 * 
+	 * @param b
+	 *            the byte array in which to store the read bytes.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte b[]) throws IOException {
+		return read(b, 0, b.length);
+	}
+
+	/**
+	 * Reads at most <code>length</code> bytes from the Stream and stores them
+	 * in byte array <code>b</code> starting at <code>offset</code>. Answer
+	 * the number of bytes actually read or -1 if no bytes were read and end of
+	 * stream was encountered.
+	 * 
+	 * @param b
+	 *            the byte array in which to store the read bytes.
+	 * @param offset
+	 *            the offset in <code>b</code> to store the read bytes.
+	 * @param length
+	 *            the maximum number of bytes to store in <code>b</code>.
+	 * @return the number of bytes actually read or -1 if end of stream.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public int read(byte b[], int offset, int length) throws IOException {
+		// avoid int overflow, check null b
+		if (offset <= b.length && 0 <= offset && 0 <= length
+				&& length <= b.length - offset) {
+			for (int i = 0; i < length; i++) {
+				int c;
+				try {
+					if ((c = read()) == -1)
+						return i == 0 ? -1 : i;
+				} catch (IOException e) {
+					if (i != 0)
+						return i;
+					throw e;
+				}
+				b[offset + i] = (byte) c;
+			}
+			return length;
+		}
+		throw new ArrayIndexOutOfBoundsException();
+	}
+
+	/**
+	 * Reset this InputStream to the last marked location. If the
+	 * <code>readlimit</code> has been passed or no <code>mark</code> has
+	 * been set, throw IOException. This implementation throws IOException and
+	 * concrete subclasses should provide proper implementations.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public synchronized void reset() throws IOException {
+		throw new IOException();
+	}
+
+	/**
+	 * Skips <code>n</code> number of bytes in this InputStream. Subsequent
+	 * <code>read()</code>'s will not return these bytes unless
+	 * <code>reset()</code> is used. This method may perform multiple reads to
+	 * read <code>n</code> bytes. This default implementation reads
+	 * <code>n</code> bytes into a temporary buffer. Concrete subclasses
+	 * should provide their own implementation.
+	 * 
+	 * @param n
+	 *            the number of bytes to skip.
+	 * @return the number of bytes actually skipped.
+	 * 
+	 * @throws IOException
+	 *             If the stream is already closed or another IOException
+	 *             occurs.
+	 */
+	public long skip(long n) throws IOException {
+		if (n <= 0)
+			return 0;
+		long skipped = 0;
+		int toRead = n < 4096 ? (int) n : 4096;
+		if (skipBuf == null || skipBuf.length < toRead)
+			skipBuf = new byte[toRead];
+		while (skipped < n) {
+			int read = read(skipBuf, 0, toRead);
+			if (read == -1)
+				return skipped;
+			skipped += read;
+			if (read < toRead)
+				return skipped;
+			if (n - skipped < toRead)
+				toRead = (int) (n - skipped);
+		}
+		return skipped;
+	}
+}



Mime
View raw message