java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
- All Implemented Interfaces:
- Closeable, Flushable
- Direct Known Subclasses:
- BufferedOutputStream, CheckedOutputStream, CipherOutputStream, DataOutputStream, DeflaterOutputStream, DigestOutputStream, PrintStream
- See Also:
- Top Examples, Source Code
public void close()
throws IOException
- See Also:
out
, flush()
, OutputStream, Closeable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[71]Reads user input from System.in
By Anonymous on 2002/10/10 17:25:32 Rate
import java.io.*;
public class MultiType {
public static void main ( String [ ] args ) {
FileOutputStream [ ] fos = new FileOutputStream [ args.length ] ;
for ( int i = 0; i < args.length; i++ ) {
try {
fos [ i ] = new FileOutputStream ( args [ i ] ) ;
}
catch ( IOException e ) {
System.err.println ( e ) ;
}
} // end for
try {
while ( true ) {
int n = System.in.available ( ) ;
if ( n > 0 ) {
byte [ ] b = new byte [ n ] ;
int result = System.in.read ( b ) ;
if ( result == -1 ) break;
for ( int i = 0; i < args.length; i++ ) {
try {
fos [ i ] .write ( b, 0, result ) ;
}
catch ( IOException e ) {
System.err.println ( e ) ;
}
} // end for
} // end if
} // end while
} // end try
catch ( IOException e ) {
System.err.println ( e ) ;
}
for ( int i = 0; i < args.length; i++ ) {
try {
fos [ i ] .close ( ) ;
}
catch ( IOException e ) {
System.err.println ( e ) ;
}
}
} // end main
}
public FilterOutputStream(OutputStream out)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void flush()
throws IOException
- See Also:
out
, OutputStream, Flushable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
protected OutputStream out
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(byte[] b)
throws IOException
- See Also:
write(byte[], int, int)
, OutputStream
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(byte[] b,
int off,
int len)
throws IOException
- See Also:
write(int)
, OutputStream
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void write(int b)
throws IOException
- See Also:
- OutputStream
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples