org.eclipse.net4j.util.io
Class IOUtil

java.lang.Object
  extended by org.eclipse.net4j.util.io.IOUtil

public final class IOUtil
extends Object


Nested Class Summary
static class IOUtil.FileCollector
           
 
Field Summary
static int DEFAULT_BUFFER_SIZE
           
static long DEFAULT_TIMEOUT
           
static int EOF
           
static String WILDCARD_MULTI_CHARS
           
static String WILDCARD_MULTI_DIRS
           
static String WILDCARD_SINGLE_CHAR
           
 
Method Summary
static void close(Closeable closeable)
           
static void close(Closeable closeable)
           
static Exception closeSilent(Closeable closeable)
           
static Exception closeSilent(Closeable closeable)
           
static void copy(InputStream input, OutputStream output)
           
static void copy(InputStream input, OutputStream output, byte[] buffer)
           
static void copy(InputStream input, OutputStream output, int bufferSize)
           
static int copy(InputStream input, OutputStream output, int size, byte[] buffer)
           
static long copyBinary(InputStream inputStream, OutputStream outputStream)
           
static void copyBinary(InputStream inputStream, OutputStream outputStream, long size)
           
static long copyCharacter(Reader reader, Writer writer)
           
static void copyCharacter(Reader reader, Writer writer, long size)
           
static void copyFile(File source, File target)
           
static void copyText(BufferedReader reader, BufferedWriter writer, IOFilter<String>... lineFilters)
           
static void copyText(File source, File target, IOFilter<String>... lineFilters)
           
static void copyTree(File source, File target)
           
static void copyTrees(Collection<File> sources, File target)
           
static int delete(File file)
           
static boolean equals(File file1, File file2)
           
static boolean equals(InputStream stream1, InputStream stream2)
           
static boolean equals(Reader reader1, Reader reader2)
           
static PrintStream ERR()
           
static void flush(Flushable flushable)
           
static IOException flushSilent(Flushable flushable)
           
static List<File> glob(String pattern, File folder)
           
static InputStream IN()
           
static List<File> listBreadthFirst(File file)
           
static List<File> listDepthFirst(File file)
           
static String makeRelative(File file, File toFolder)
           
static void mkdirs(File folder)
           
static String normalizeSeparator(String string)
           
static FileInputStream openInputStream(File file)
           
static FileInputStream openInputStream(String fileName)
           
static FileOutputStream openOutputStream(File file)
           
static FileOutputStream openOutputStream(String fileName)
           
static FileReader openReader(File file)
           
static FileReader openReader(String fileName)
           
static FileWriter openWriter(File file)
           
static FileWriter openWriter(String fileName)
           
static PrintStream OUT()
           
static void print(StackTraceElement[] elements)
           
static void print(StackTraceElement[] elements, PrintStream stream)
           
static void print(Throwable t)
           
static void print(Throwable t, PrintStream stream)
           
static byte[] readFile(File file)
           
static String readTextFile(File file)
           
static void safeInput(File file, IORunnable<FileInputStream> runnable)
           
static void safeOutput(File file, IORunnable<FileOutputStream> runnable)
           
static void safeRead(File file, IORunnable<FileReader> runnable)
           
static
<IO extends Closeable>
void
safeRun(IO io, IORunnable<IO> runnable)
           
static void safeWrite(File file, IORunnable<FileWriter> runnable)
           
static String toString(Throwable t)
           
static void visitBreadthFirst(File[] files, IOVisitor visitor)
           
static void visitBreadthFirst(File file, IOVisitor visitor)
           
static void visitDepthFirst(File[] files, IOVisitor visitor)
           
static void visitDepthFirst(File file, IOVisitor visitor)
           
static void writeFile(File file, byte[] bytes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOF

public static final int EOF
Since:
3.1
See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final long DEFAULT_TIMEOUT
Since:
3.1
See Also:
Constant Field Values

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values

WILDCARD_SINGLE_CHAR

public static final String WILDCARD_SINGLE_CHAR
Since:
2.0
See Also:
Constant Field Values

WILDCARD_MULTI_CHARS

public static final String WILDCARD_MULTI_CHARS
Since:
2.0
See Also:
Constant Field Values

WILDCARD_MULTI_DIRS

public static final String WILDCARD_MULTI_DIRS
Since:
2.0
See Also:
Constant Field Values
Method Detail

IN

public static InputStream IN()

OUT

public static PrintStream OUT()

ERR

public static PrintStream ERR()

print

public static void print(StackTraceElement[] elements)
Since:
3.1

print

public static void print(StackTraceElement[] elements,
                         PrintStream stream)
Since:
3.1

print

public static void print(Throwable t,
                         PrintStream stream)

print

public static void print(Throwable t)

toString

public static String toString(Throwable t)
Since:
2.0

openInputStream

public static FileInputStream openInputStream(String fileName)
                                       throws IORuntimeException
Throws:
IORuntimeException

openInputStream

public static FileInputStream openInputStream(File file)
                                       throws IORuntimeException
Throws:
IORuntimeException

openOutputStream

public static FileOutputStream openOutputStream(String fileName)
                                         throws IORuntimeException
Throws:
IORuntimeException

openOutputStream

public static FileOutputStream openOutputStream(File file)
                                         throws IORuntimeException
Throws:
IORuntimeException

openReader

public static FileReader openReader(String fileName)
                             throws IORuntimeException
Throws:
IORuntimeException

openReader

public static FileReader openReader(File file)
                             throws IORuntimeException
Throws:
IORuntimeException

openWriter

public static FileWriter openWriter(String fileName)
                             throws IORuntimeException
Throws:
IORuntimeException

openWriter

public static FileWriter openWriter(File file)
                             throws IORuntimeException
Throws:
IORuntimeException

closeSilent

public static Exception closeSilent(Closeable closeable)

close

public static void close(Closeable closeable)
                  throws IORuntimeException
Throws:
IORuntimeException

closeSilent

public static Exception closeSilent(Closeable closeable)

close

public static void close(Closeable closeable)
                  throws IORuntimeException
Throws:
IORuntimeException

flushSilent

public static IOException flushSilent(Flushable flushable)
Since:
3.3

flush

public static void flush(Flushable flushable)
                  throws IORuntimeException
Throws:
IORuntimeException
Since:
3.3

makeRelative

public static String makeRelative(File file,
                                  File toFolder)
Since:
2.0

normalizeSeparator

public static String normalizeSeparator(String string)
Since:
2.0

mkdirs

public static void mkdirs(File folder)

delete

public static int delete(File file)

copyTree

public static void copyTree(File source,
                            File target)
                     throws IORuntimeException
Throws:
IORuntimeException

copyTrees

public static void copyTrees(Collection<File> sources,
                             File target)
                      throws IORuntimeException
Throws:
IORuntimeException

copyText

public static void copyText(File source,
                            File target,
                            IOFilter<String>... lineFilters)
                     throws IORuntimeException
Throws:
IORuntimeException

copyText

public static void copyText(BufferedReader reader,
                            BufferedWriter writer,
                            IOFilter<String>... lineFilters)

copyBinary

public static long copyBinary(InputStream inputStream,
                              OutputStream outputStream)
                       throws IOException
Throws:
IOException
Since:
3.1

copyBinary

public static void copyBinary(InputStream inputStream,
                              OutputStream outputStream,
                              long size)
                       throws IOException
Throws:
IOException
Since:
3.1

copyCharacter

public static long copyCharacter(Reader reader,
                                 Writer writer)
                          throws IOException
Throws:
IOException
Since:
3.1

copyCharacter

public static void copyCharacter(Reader reader,
                                 Writer writer,
                                 long size)
                          throws IOException
Throws:
IOException
Since:
3.1

copy

public static int copy(InputStream input,
                       OutputStream output,
                       int size,
                       byte[] buffer)
                throws IORuntimeException
Throws:
IORuntimeException

copy

public static void copy(InputStream input,
                        OutputStream output,
                        byte[] buffer)
                 throws IORuntimeException
Throws:
IORuntimeException

copy

public static void copy(InputStream input,
                        OutputStream output,
                        int bufferSize)
                 throws IORuntimeException
Throws:
IORuntimeException

copy

public static void copy(InputStream input,
                        OutputStream output)
                 throws IORuntimeException
Throws:
IORuntimeException

copyFile

public static void copyFile(File source,
                            File target)
                     throws IORuntimeException
Throws:
IORuntimeException
See Also:
NIOUtil.copyFile(File, File)

readTextFile

public static String readTextFile(File file)
                           throws IORuntimeException
Throws:
IORuntimeException
Since:
3.1

readFile

public static byte[] readFile(File file)
                       throws IORuntimeException
Throws:
IORuntimeException

writeFile

public static void writeFile(File file,
                             byte[] bytes)
                      throws IORuntimeException
Throws:
IORuntimeException

listDepthFirst

public static List<File> listDepthFirst(File file)

listBreadthFirst

public static List<File> listBreadthFirst(File file)

visitDepthFirst

public static void visitDepthFirst(File file,
                                   IOVisitor visitor)
                            throws IORuntimeException
Throws:
IORuntimeException

visitDepthFirst

public static void visitDepthFirst(File[] files,
                                   IOVisitor visitor)

visitBreadthFirst

public static void visitBreadthFirst(File file,
                                     IOVisitor visitor)
                              throws IORuntimeException
Throws:
IORuntimeException

visitBreadthFirst

public static void visitBreadthFirst(File[] files,
                                     IOVisitor visitor)
                              throws IORuntimeException
Throws:
IORuntimeException

safeRun

public static <IO extends Closeable> void safeRun(IO io,
                                                  IORunnable<IO> runnable)
                    throws IORuntimeException
Throws:
IORuntimeException

safeInput

public static void safeInput(File file,
                             IORunnable<FileInputStream> runnable)
                      throws IORuntimeException
Throws:
IORuntimeException

safeOutput

public static void safeOutput(File file,
                              IORunnable<FileOutputStream> runnable)
                       throws IORuntimeException
Throws:
IORuntimeException

safeRead

public static void safeRead(File file,
                            IORunnable<FileReader> runnable)
                     throws IORuntimeException
Throws:
IORuntimeException

safeWrite

public static void safeWrite(File file,
                             IORunnable<FileWriter> runnable)
                      throws IORuntimeException
Throws:
IORuntimeException

equals

public static boolean equals(InputStream stream1,
                             InputStream stream2)
                      throws IORuntimeException
Throws:
IORuntimeException

equals

public static boolean equals(Reader reader1,
                             Reader reader2)
                      throws IORuntimeException
Throws:
IORuntimeException
Since:
3.2

equals

public static boolean equals(File file1,
                             File file2)
                      throws IORuntimeException
Throws:
IORuntimeException

glob

public static List<File> glob(String pattern,
                              File folder)
Since:
2.0


Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.