aQute.lib.io
Class IO

java.lang.Object
  extended by aQute.lib.io.IO

public class IO
extends Object


Field Summary
static File home
           
static OutputStream nullStream
           
static Writer nullWriter
           
static File work
           
 
Constructor Summary
IO()
           
 
Method Summary
static Throwable close(Closeable in)
           
static String collect(File a)
           
static String collect(File a, String encoding)
           
static String collect(InputStream a)
           
static String collect(InputStream a, String encoding)
           
static String collect(Reader a)
           
static String collect(String a)
           
static String collect(URL a)
           
static String collect(URL a, String encoding)
           
static void copy(byte[] r, OutputStream w)
           
static void copy(byte[] r, Writer w)
           
 void copy(Collection<?> c, OutputStream out)
           
static void copy(File a, File b)
           
static void copy(File in, MessageDigest md)
           
static void copy(File a, OutputStream b)
           
static void copy(InputStream in, ByteBuffer bb)
           
static void copy(InputStream in, DataOutput out)
           
static void copy(InputStream a, File b)
           
static void copy(InputStream in, MessageDigest md)
           
static void copy(InputStream in, OutputStream out)
           
static void copy(InputStream in, URL out)
           
static void copy(InputStream in, URL out, String method)
           
static void copy(InputStream r, Writer w)
           
static void copy(InputStream r, Writer w, String charset)
           
static void copy(Reader r, OutputStream o)
           
static void copy(Reader r, OutputStream o, String charset)
           
static void copy(Reader r, Writer w)
           
static void copy(URLConnection c, File file)
           
static void copy(URLConnection in, MessageDigest md)
           
static void copy(URL url, File file)
           
static void copy(URL in, MessageDigest md)
           
static File createTempFile(File directory, String pattern, String suffix)
          Create a temporary file.
static void delete(File f)
          Deletes the specified file.
static void deleteWithException(File f)
          Deletes the specified file.
static long drain(InputStream in)
           
static File getFile(File base, String file)
           
static File getFile(String filename)
           
static byte[] read(File f)
           
static byte[] read(InputStream in)
           
static byte[] read(URL u)
           
static BufferedReader reader(File f)
           
static BufferedReader reader(File f, String encoding)
           
static BufferedReader reader(InputStream in)
           
static BufferedReader reader(InputStream in, String encoding)
           
static Reader reader(String s)
           
static void rename(File from, File to)
          Deletes to file if it exists, and renames from file to to.
Throws exception the rename operation fails.
static void store(Object o, File out)
           
static void store(Object o, File out, String encoding)
           
static void store(Object o, OutputStream fout)
           
static void store(Object o, OutputStream fout, String encoding)
           
static InputStream stream(File s)
           
static InputStream stream(String s)
           
static InputStream stream(String s, String encoding)
           
static InputStream stream(URL s)
           
static URL toURL(String s, File base)
           
static void write(byte[] data, File out)
           
static void write(byte[] data, OutputStream out)
           
static PrintWriter writer(File f)
           
static PrintWriter writer(File f, String encoding)
           
static PrintWriter writer(OutputStream out)
           
static PrintWriter writer(OutputStream out, String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

work

public static final File work

home

public static final File home

nullStream

public static OutputStream nullStream

nullWriter

public static Writer nullWriter
Constructor Detail

IO

public IO()
Method Detail

copy

public static void copy(Reader r,
                        Writer w)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream r,
                        Writer w)
                 throws IOException
Throws:
IOException

copy

public static void copy(byte[] r,
                        Writer w)
                 throws IOException
Throws:
IOException

copy

public static void copy(byte[] r,
                        OutputStream w)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream r,
                        Writer w,
                        String charset)
                 throws IOException
Throws:
IOException

copy

public static void copy(Reader r,
                        OutputStream o)
                 throws IOException
Throws:
IOException

copy

public static void copy(Reader r,
                        OutputStream o,
                        String charset)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        DataOutput out)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        ByteBuffer bb)
                 throws IOException
Throws:
IOException

copy

public static void copy(URL in,
                        MessageDigest md)
                 throws IOException
Throws:
IOException

copy

public static void copy(File in,
                        MessageDigest md)
                 throws IOException
Throws:
IOException

copy

public static void copy(URLConnection in,
                        MessageDigest md)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        MessageDigest md)
                 throws IOException
Throws:
IOException

copy

public static void copy(URL url,
                        File file)
                 throws IOException
Throws:
IOException

copy

public static void copy(URLConnection c,
                        File file)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        URL out)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream in,
                        URL out,
                        String method)
                 throws IOException
Throws:
IOException

copy

public static void copy(File a,
                        File b)
                 throws IOException
Throws:
IOException

copy

public static void copy(InputStream a,
                        File b)
                 throws IOException
Throws:
IOException

copy

public static void copy(File a,
                        OutputStream b)
                 throws IOException
Throws:
IOException

read

public static byte[] read(File f)
                   throws IOException
Throws:
IOException

read

public static byte[] read(URL u)
                   throws IOException
Throws:
IOException

read

public static byte[] read(InputStream in)
                   throws IOException
Throws:
IOException

write

public static void write(byte[] data,
                         OutputStream out)
                  throws Exception
Throws:
Exception

write

public static void write(byte[] data,
                         File out)
                  throws Exception
Throws:
Exception

collect

public static String collect(File a,
                             String encoding)
                      throws IOException
Throws:
IOException

collect

public static String collect(URL a,
                             String encoding)
                      throws IOException
Throws:
IOException

collect

public static String collect(URL a)
                      throws IOException
Throws:
IOException

collect

public static String collect(File a)
                      throws IOException
Throws:
IOException

collect

public static String collect(String a)
                      throws IOException
Throws:
IOException

collect

public static String collect(InputStream a,
                             String encoding)
                      throws IOException
Throws:
IOException

collect

public static String collect(InputStream a)
                      throws IOException
Throws:
IOException

collect

public static String collect(Reader a)
                      throws IOException
Throws:
IOException

createTempFile

public static File createTempFile(File directory,
                                  String pattern,
                                  String suffix)
                           throws IllegalArgumentException,
                                  IOException
Create a temporary file.

Parameters:
directory - the directory in which to create the file. Can be null, in which case the system TMP directory is used
pattern - the filename prefix pattern. Must be at least 3 characters long
suffix - the filename suffix. Can be null, in which case (system) default suffix is used
Returns:
Throws:
IllegalArgumentException - when pattern is null or too short
IOException - when the specified (non-null) directory is not a directory

getFile

public static File getFile(String filename)

getFile

public static File getFile(File base,
                           String file)

delete

public static void delete(File f)
Deletes the specified file. Folders are recursively deleted.
If file(s) cannot be deleted, no feedback is provided (fail silently).

Parameters:
f - file to be deleted

deleteWithException

public static void deleteWithException(File f)
                                throws IOException
Deletes the specified file. Folders are recursively deleted.
Throws exception if any of the files could not be deleted.

Parameters:
f - file to be deleted
Throws:
IOException - if the file (or contents of a folder) could not be deleted

rename

public static void rename(File from,
                          File to)
                   throws IOException
Deletes to file if it exists, and renames from file to to.
Throws exception the rename operation fails.

Parameters:
from - source file
to - destination file
Throws:
IOException - if the rename operation fails

drain

public static long drain(InputStream in)
                  throws IOException
Throws:
IOException

copy

public void copy(Collection<?> c,
                 OutputStream out)
          throws IOException
Throws:
IOException

close

public static Throwable close(Closeable in)

toURL

public static URL toURL(String s,
                        File base)
                 throws MalformedURLException
Throws:
MalformedURLException

store

public static void store(Object o,
                         File out)
                  throws IOException
Throws:
IOException

store

public static void store(Object o,
                         File out,
                         String encoding)
                  throws IOException
Throws:
IOException

store

public static void store(Object o,
                         OutputStream fout)
                  throws UnsupportedEncodingException,
                         IOException
Throws:
UnsupportedEncodingException
IOException

store

public static void store(Object o,
                         OutputStream fout,
                         String encoding)
                  throws UnsupportedEncodingException,
                         IOException
Throws:
UnsupportedEncodingException
IOException

stream

public static InputStream stream(String s)

stream

public static InputStream stream(String s,
                                 String encoding)
                          throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

stream

public static InputStream stream(File s)
                          throws FileNotFoundException
Throws:
FileNotFoundException

stream

public static InputStream stream(URL s)
                          throws IOException
Throws:
IOException

reader

public static Reader reader(String s)

reader

public static BufferedReader reader(File f,
                                    String encoding)
                             throws IOException
Throws:
IOException

reader

public static BufferedReader reader(File f)
                             throws IOException
Throws:
IOException

writer

public static PrintWriter writer(File f,
                                 String encoding)
                          throws IOException
Throws:
IOException

writer

public static PrintWriter writer(File f)
                          throws IOException
Throws:
IOException

writer

public static PrintWriter writer(OutputStream out,
                                 String encoding)
                          throws IOException
Throws:
IOException

reader

public static BufferedReader reader(InputStream in,
                                    String encoding)
                             throws IOException
Throws:
IOException

reader

public static BufferedReader reader(InputStream in)
                             throws IOException
Throws:
IOException

writer

public static PrintWriter writer(OutputStream out)
                          throws IOException
Throws:
IOException


Copyright © 2014 aQute SARL. All rights reserved.