NIO2 API

org.classpath.icedtea.java.io
Class Outputs

java.lang.Object
  extended by org.classpath.icedtea.java.io.Outputs

public final class Outputs
extends java.lang.Object

This class consists exclusively of static methods that operate on output destinations.

The methods to write lines of text output a line terminator following each line. The line terminator that is output is platform line terminated, as defined by the line.separator system property.

Since:
1.7

Method Summary
static void write(File file, byte[] bytes)
          Writes a byte array to a file.
static void write(File file, byte[] bytes, int off, int len)
          Writes a byte array to a file.
static void write(FileRef file, byte[] bytes)
          Writes a byte array to a file.
static void write(FileRef file, byte[] bytes, int off, int len)
          Writes a byte array to a file.
static void writeLines(File file, java.util.List<java.lang.String> lines)
          Writes the given lines of text to the specified file.
static void writeLines(File file, java.util.List<java.lang.String> lines, java.lang.String csn)
          Writes the given lines of text to the specified file.
static void writeLines(FileRef file, java.util.List<java.lang.String> lines)
          Writes the given lines of text to the specified file.
static void writeLines(FileRef file, java.util.List<java.lang.String> lines, java.lang.String csn)
          Writes the given lines of text to the specified file.
static void writeLines(FileRef file, java.lang.String... lines)
          Writes the given lines of text to the specified file.
static void writeLines(File file, java.lang.String... lines)
          Writes the given lines of text to the specified file.
static void writeLines(java.io.OutputStream out, java.util.List<java.lang.String> lines)
          Writes the given lines of text to the specified output stream.
static void writeLines(java.io.OutputStream out, java.util.List<java.lang.String> lines, java.lang.String csn)
          Writes the given lines of text to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

write

public static void write(FileRef file,
                         byte[] bytes)
                  throws java.io.IOException
Writes a byte array to a file. The file is created if it does not exist. If the file already exists, it is first truncated.

Throws:
java.io.IOException - If an I/O error occurs

write

public static void write(FileRef file,
                         byte[] bytes,
                         int off,
                         int len)
                  throws java.io.IOException
Writes a byte array to a file. The file is created if it does not exist. If the file already exists, it is first truncated.

Throws:
java.lang.IndexOutOfBoundsException - If off or len is negative, or off+len is greater than the length of the array
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(FileRef file,
                              java.util.List<java.lang.String> lines,
                              java.lang.String csn)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the specified charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The list of lines to write (in order)
csn - The name of the charset to be used
Throws:
java.nio.charset.UnsupportedCharsetException - If no support for the named charset is available in this instance of the Java virtual machine
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(FileRef file,
                              java.util.List<java.lang.String> lines)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the underlying platform's default charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The list of lines to write (in order)
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(FileRef file,
                              java.lang.String... lines)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the underlying platform's default charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The array of lines to write (in order)
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

write

public static void write(File file,
                         byte[] bytes)
                  throws java.io.IOException
Writes a byte array to a file. The file is created if it does not exist. If the file already exists, it is first truncated.

Parameters:
file - The file
bytes - The byte array to write to the file
Throws:
java.io.IOException - If an I/O error occurs

write

public static void write(File file,
                         byte[] bytes,
                         int off,
                         int len)
                  throws java.io.IOException
Writes a byte array to a file. The file is created if it does not exist. If the file already exists, it is first truncated.

Throws:
java.lang.IndexOutOfBoundsException - If off or len is negative, or off+len is greater than the length of the array
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(File file,
                              java.util.List<java.lang.String> lines,
                              java.lang.String csn)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the specified charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The list of lines to write (in order)
csn - The name of the charset to be used
Throws:
java.nio.charset.UnsupportedCharsetException - If no support for the named charset is available in this instance of the Java virtual machine
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(File file,
                              java.util.List<java.lang.String> lines)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the underlying platform's default charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The list of lines to write (in order)
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(File file,
                              java.lang.String... lines)
                       throws java.io.IOException
Writes the given lines of text to the specified file. The characters in each line are encoded into bytes using the underlying platform's default charset. When all lines have been written, or an I/O error occurs, then the file is closed.

Parameters:
file - The file
lines - The array of lines to write (in order)
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(java.io.OutputStream out,
                              java.util.List<java.lang.String> lines,
                              java.lang.String csn)
                       throws java.io.IOException
Writes the given lines of text to the specified output stream. The characters in each line are encoded into bytes using the specified charset.

Parameters:
out - The output stream
lines - The list of lines to write (in order)
csn - The name of the charset to be used
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

writeLines

public static void writeLines(java.io.OutputStream out,
                              java.util.List<java.lang.String> lines)
                       throws java.io.IOException
Writes the given lines of text to the specified output stream. The characters in each line are encoded into bytes using the underlying platform's default charset.

Parameters:
out - The output stream
lines - The list of lines to write (in order)
Throws:
java.nio.charset.UnmappableCharacterException - Where a line contains a character that cannot be mapped to an output byte sequence
java.io.IOException - If an I/O error occurs

NIO2 API

Submit a bug or feature

Copyright 2010 Sun Microsystems, Inc. All rights reserved. Use is subject to the terms of the GNU General Public License.