org.eobjects.metamodel.util
Class FileHelper

java.lang.Object
  extended by org.eobjects.metamodel.util.FileHelper

public final class FileHelper
extends Object

Various helper methods for handling files


Field Summary
static String DEFAULT_ENCODING
           
static String ISO_8859_1_ENCODING
           
static String US_ASCII_ENCODING
           
static String UTF_16_ENCODING
           
static String UTF_8_ENCODING
           
 
Method Summary
static void copy(File from, File to)
           
static void copy(InputStream fromStream, OutputStream toStream)
           
static void copy(Reader reader, Writer writer)
           
static File createTempFile(String prefix, String suffix)
           
static BufferedReader getBufferedReader(File file)
           
static BufferedReader getBufferedReader(File file, String encoding)
           
static BufferedReader getBufferedReader(InputStream inputStream, String encoding)
           
static BufferedReader getBufferedReader(Reader reader)
           
static BufferedWriter getBufferedWriter(File file)
           
static BufferedWriter getBufferedWriter(File file, String encoding)
           
static InputStream getInputStream(File file)
           
static OutputStream getOutputStream(File file)
           
static OutputStream getOutputStream(File file, boolean append)
           
static Reader getReader(File file)
           
static Reader getReader(File file, String encoding)
           
static Reader getReader(InputStream inputStream, String encoding)
           
static File getTempDir()
           
static Writer getWriter(File file)
           
static Writer getWriter(File file, String encoding)
           
static Writer getWriter(File file, String encoding, boolean append)
           
static Writer getWriter(File file, String encoding, boolean append, boolean insertBom)
           
static Writer getWriter(OutputStream outputStream, String encoding)
           
static Writer getWriter(OutputStream outputStream, String encoding, boolean insertBom)
           
static byte[] readAsBytes(InputStream inputStream)
           
static String readAsString(Reader reader)
           
static String readFileAsString(File file)
           
static String readFileAsString(File file, String encoding)
           
static String readInputStreamAsString(InputStream inputStream, String encoding)
           
static void safeClose(Object... objects)
           
static void writeString(OutputStream outputStream, String string)
           
static void writeString(OutputStream outputStream, String string, String encoding)
           
static void writeString(Writer writer, String string)
           
static void writeString(Writer writer, String string, String encoding)
           
static void writeStringAsFile(File file, String string)
           
static void writeStringAsFile(File file, String string, String encoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF_8_ENCODING

public static final String UTF_8_ENCODING
See Also:
Constant Field Values

UTF_16_ENCODING

public static final String UTF_16_ENCODING
See Also:
Constant Field Values

US_ASCII_ENCODING

public static final String US_ASCII_ENCODING
See Also:
Constant Field Values

ISO_8859_1_ENCODING

public static final String ISO_8859_1_ENCODING
See Also:
Constant Field Values

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values
Method Detail

createTempFile

public static File createTempFile(String prefix,
                                  String suffix)

getTempDir

public static File getTempDir()

getWriter

public static Writer getWriter(File file,
                               String encoding,
                               boolean append)
                        throws IllegalStateException
Throws:
IllegalStateException

getWriter

public static Writer getWriter(OutputStream outputStream,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

getWriter

public static Writer getWriter(OutputStream outputStream,
                               String encoding,
                               boolean insertBom)
                        throws IllegalStateException
Throws:
IllegalStateException

getWriter

public static Writer getWriter(File file,
                               String encoding,
                               boolean append,
                               boolean insertBom)
                        throws IllegalStateException
Throws:
IllegalStateException

getWriter

public static Writer getWriter(File file,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

getReader

public static Reader getReader(InputStream inputStream,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

getReader

public static Reader getReader(File file,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

readInputStreamAsString

public static String readInputStreamAsString(InputStream inputStream,
                                             String encoding)
                                      throws IllegalStateException
Throws:
IllegalStateException

readFileAsString

public static String readFileAsString(File file,
                                      String encoding)
                               throws IllegalStateException
Throws:
IllegalStateException

readAsString

public static String readAsString(Reader reader)
                           throws IllegalStateException
Throws:
IllegalStateException

safeClose

public static void safeClose(Object... objects)

getBufferedWriter

public static BufferedWriter getBufferedWriter(File file,
                                               String encoding)
                                        throws IllegalStateException
Throws:
IllegalStateException

getBufferedReader

public static BufferedReader getBufferedReader(File file,
                                               String encoding)
                                        throws IllegalStateException
Throws:
IllegalStateException

getBufferedReader

public static BufferedReader getBufferedReader(InputStream inputStream,
                                               String encoding)
                                        throws IllegalStateException
Throws:
IllegalStateException

getReader

public static Reader getReader(File file)
                        throws IllegalStateException
Throws:
IllegalStateException

readFileAsString

public static String readFileAsString(File file)
                               throws IllegalStateException
Throws:
IllegalStateException

getBufferedWriter

public static BufferedWriter getBufferedWriter(File file)
                                        throws IllegalStateException
Throws:
IllegalStateException

getWriter

public static Writer getWriter(File file)
                        throws IllegalStateException
Throws:
IllegalStateException

writeString

public static void writeString(OutputStream outputStream,
                               String string)
                        throws IllegalStateException
Throws:
IllegalStateException

writeString

public static void writeString(OutputStream outputStream,
                               String string,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

writeString

public static void writeString(Writer writer,
                               String string)
                        throws IllegalStateException
Throws:
IllegalStateException

writeString

public static void writeString(Writer writer,
                               String string,
                               String encoding)
                        throws IllegalStateException
Throws:
IllegalStateException

writeStringAsFile

public static void writeStringAsFile(File file,
                                     String string)
                              throws IllegalStateException
Throws:
IllegalStateException

writeStringAsFile

public static void writeStringAsFile(File file,
                                     String string,
                                     String encoding)
                              throws IllegalStateException
Throws:
IllegalStateException

getBufferedReader

public static BufferedReader getBufferedReader(File file)
                                        throws IllegalStateException
Throws:
IllegalStateException

copy

public static void copy(Reader reader,
                        Writer writer)
                 throws IllegalStateException
Throws:
IllegalStateException

getBufferedReader

public static BufferedReader getBufferedReader(Reader reader)

copy

public static void copy(InputStream fromStream,
                        OutputStream toStream)
                 throws IllegalStateException
Throws:
IllegalStateException

copy

public static void copy(File from,
                        File to)
                 throws IllegalStateException
Throws:
IllegalStateException

getOutputStream

public static OutputStream getOutputStream(File file)
                                    throws IllegalStateException
Throws:
IllegalStateException

getOutputStream

public static OutputStream getOutputStream(File file,
                                           boolean append)

getInputStream

public static InputStream getInputStream(File file)
                                  throws IllegalStateException
Throws:
IllegalStateException

readAsBytes

public static byte[] readAsBytes(InputStream inputStream)


Copyright © 2007-2013. All Rights Reserved.