org.tridas.io.util
Class IOUtils

java.lang.Object
  extended by org.tridas.io.util.IOUtils

public class IOUtils
extends Object

Static IO utility methods

Author:
daniel

Method Summary
static InputStream createInput(File file)
           
static OutputStream createOutput(File file)
           
static void createPath(String filename)
          Takes a path and creates any in-between folders if they don't already exist.
static BufferedReader createReader(File file)
          I want to read lines from a file.
static BufferedReader createReader(File file, String argEncoding)
          I want to read lines from a file.
static BufferedReader createReader(InputStream input)
          I want to read lines from a stream.
static BufferedReader createReader(InputStream input, String argEncoding)
          I want to read lines from a stream.
static PrintWriter createWriter(File file)
          I want to print lines to a file.
static PrintWriter createWriter(File file, String argEncoding)
          I want to print lines to a file.
static PrintWriter createWriter(OutputStream output)
          I want to print lines to a file.
static PrintWriter createWriter(OutputStream output, String argEncoding)
          I want to print lines to a file.
static Charset detectCharset(byte[] argBytes)
           
static URL getFileInJarURL(String argFile)
           
static File inputFile(JFrame argParent)
           
static File inputFile(String argPrompt, JFrame argParentFrame)
          The parentFrame is the Frame that will guide the placement of the prompt window.
static File[] inputFiles(JFrame argParent)
           
static File[] inputFiles(String argPrompt, JFrame argParentFrame)
           
static byte[] loadBytes(InputStream input)
           
static String[] loadStrings(File file)
           
static String[] loadStrings(File file, String argEncoding)
           
static String[] loadStrings(InputStream input)
           
static String[] loadStrings(InputStream input, String argEncoding)
           
static File outputFile(JFrame parentFrame)
           
static File outputFile(String argPrompt, JFrame argParentFrame)
          The parentFrame is the Frame that will guide the placement of the prompt window.
static File[] outputFiles(JFrame argParentFrame)
           
static File[] outputFiles(String argPrompt, JFrame argParentFrame)
           
static File outputFolder(JFrame argParent)
           
static File outputFolder(String argPrompt, JFrame argParentFrame)
           
static void saveBytes(File file, byte[] buffer)
          Saves bytes to a specific File location specified by the user.
static void saveBytes(OutputStream output, byte[] buffer)
          Spews a buffer of bytes to an OutputStream.
static void saveStream(File targetFile, InputStream sourceStream)
           
static void saveStrings(File file, String[] strings)
           
static void saveStrings(File file, String[] strings, String argEncoding)
           
static void saveStrings(OutputStream output, String[] strings)
           
static void saveStrings(OutputStream output, String[] strings, String argEncoding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

inputFile

public static File inputFile(JFrame argParent)

inputFiles

public static File[] inputFiles(JFrame argParent)

outputFolder

public static File outputFolder(JFrame argParent)

inputFile

public static File inputFile(String argPrompt,
                             JFrame argParentFrame)
The parentFrame is the Frame that will guide the placement of the prompt window. If no Frame is available, just pass in null.


inputFiles

public static File[] inputFiles(String argPrompt,
                                JFrame argParentFrame)

outputFile

public static File outputFile(JFrame parentFrame)

outputFiles

public static File[] outputFiles(JFrame argParentFrame)

outputFile

public static File outputFile(String argPrompt,
                              JFrame argParentFrame)
The parentFrame is the Frame that will guide the placement of the prompt window. If no Frame is available, just pass in null.


outputFolder

public static File outputFolder(String argPrompt,
                                JFrame argParentFrame)

outputFiles

public static File[] outputFiles(String argPrompt,
                                 JFrame argParentFrame)

createReader

public static BufferedReader createReader(File file)
I want to read lines from a file.


createReader

public static BufferedReader createReader(File file,
                                          String argEncoding)
                                   throws UnsupportedEncodingException
I want to read lines from a file. with an encoding!

Throws:
UnsupportedEncodingException

createReader

public static BufferedReader createReader(InputStream input)
I want to read lines from a stream.


createReader

public static BufferedReader createReader(InputStream input,
                                          String argEncoding)
                                   throws UnsupportedEncodingException
I want to read lines from a stream. with an encoding!

Throws:
UnsupportedEncodingException

createWriter

public static PrintWriter createWriter(File file)
I want to print lines to a file.


createWriter

public static PrintWriter createWriter(File file,
                                       String argEncoding)
                                throws UnsupportedEncodingException
I want to print lines to a file.

Throws:
UnsupportedEncodingException

createWriter

public static PrintWriter createWriter(OutputStream output)
I want to print lines to a file.


createWriter

public static PrintWriter createWriter(OutputStream output,
                                       String argEncoding)
                                throws UnsupportedEncodingException
I want to print lines to a file.

Throws:
UnsupportedEncodingException

getFileInJarURL

public static URL getFileInJarURL(String argFile)

createInput

public static InputStream createInput(File file)

loadBytes

public static byte[] loadBytes(InputStream input)

loadStrings

public static String[] loadStrings(File file)

loadStrings

public static String[] loadStrings(File file,
                                   String argEncoding)
                            throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

loadStrings

public static String[] loadStrings(InputStream input)

loadStrings

public static String[] loadStrings(InputStream input,
                                   String argEncoding)
                            throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

createOutput

public static OutputStream createOutput(File file)

saveStream

public static void saveStream(File targetFile,
                              InputStream sourceStream)

saveBytes

public static void saveBytes(File file,
                             byte[] buffer)
Saves bytes to a specific File location specified by the user.


saveBytes

public static void saveBytes(OutputStream output,
                             byte[] buffer)
Spews a buffer of bytes to an OutputStream.


saveStrings

public static void saveStrings(File file,
                               String[] strings)

saveStrings

public static void saveStrings(File file,
                               String[] strings,
                               String argEncoding)
                        throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

saveStrings

public static void saveStrings(OutputStream output,
                               String[] strings)

saveStrings

public static void saveStrings(OutputStream output,
                               String[] strings,
                               String argEncoding)
                        throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

createPath

public static void createPath(String filename)
Takes a path and creates any in-between folders if they don't already exist. Useful when trying to save to a subfolder that may not actually exist.


detectCharset

public static Charset detectCharset(byte[] argBytes)


Copyright © 2011. All Rights Reserved.