org.rapla.components.util
Class IOUtil

java.lang.Object
  extended by org.rapla.components.util.IOUtil

public abstract class IOUtil
extends Object

Some IOHelper methods.


Constructor Summary
IOUtil()
           
 
Method Summary
static void copy(File srcFile, File destFile, boolean onlyOverwriteIfNewer)
          copies a file.
static void copy(String srcPath, String destPath)
          copies a file.
static void copy(String srcPath, String destPath, boolean onlyOverwriteIfNewer)
          copies a file.
static void copyStreams(InputStream in, OutputStream out)
          copies the contents of the input stream to the output stream.
static String decode(String s, String enc)
          same as URLDecoder.decode(java.lang.String).
static String encode(String s, String enc)
          same as URLEncoder.encode(java.lang.String).
static URL getBase(URL url)
          returns the path of the url without the last path component
static File getFileFrom(URL url)
           
static InputStream getInputStream(URL url)
          returns a BufferedInputStream from the url.
static File[] getJarFiles(String baseDir, String dirList)
           
static String getRelativePath(File base, File file)
          returns the relative path of file to base.
static String getRelativeURL(File base, File file)
          returns the relative path of file to base.
static String getStackTraceAsString(Throwable ex)
           
static byte[] readBytes(URL url)
          reads the content form an url into a ByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtil

public IOUtil()
Method Detail

getBase

public static URL getBase(URL url)
returns the path of the url without the last path component


readBytes

public static byte[] readBytes(URL url)
                        throws IOException
reads the content form an url into a ByteArray

Throws:
IOException

decode

public static String decode(String s,
                            String enc)
                     throws UnsupportedEncodingException
same as URLDecoder.decode(java.lang.String). But calls the deprecated method under 1.3.

Throws:
UnsupportedEncodingException

encode

public static String encode(String s,
                            String enc)
                     throws UnsupportedEncodingException
same as URLEncoder.encode(java.lang.String). But calls the deprecated method under 1.3.

Throws:
UnsupportedEncodingException

getInputStream

public static InputStream getInputStream(URL url)
                                  throws IOException
returns a BufferedInputStream from the url. If the url-protocol is "file" no url connection will be opened.

Throws:
IOException

getFileFrom

public static File getFileFrom(URL url)
                        throws IOException
Throws:
IOException

copy

public static void copy(String srcPath,
                        String destPath)
                 throws IOException
copies a file.

Parameters:
srcPath - the source-path. Thats the path of the file that should be copied.
destPath - the destination-path
Throws:
IOException

copy

public static void copy(String srcPath,
                        String destPath,
                        boolean onlyOverwriteIfNewer)
                 throws IOException
copies a file.

Parameters:
srcPath - the source-path. Thats the path of the file that should be copied.
destPath - the destination-path
Throws:
IOException

copy

public static void copy(File srcFile,
                        File destFile,
                        boolean onlyOverwriteIfNewer)
                 throws IOException
copies a file.

Throws:
IOException

copyStreams

public static void copyStreams(InputStream in,
                               OutputStream out)
                        throws IOException
copies the contents of the input stream to the output stream.

Parameters:
in -
out -
Throws:
IOException

getRelativePath

public static String getRelativePath(File base,
                                     File file)
                              throws IOException
returns the relative path of file to base.

Throws:
IOException - if position of file is not relative to base

getRelativeURL

public static String getRelativeURL(File base,
                                    File file)
                             throws IOException
returns the relative path of file to base. same as getRelativePath(File, File) but replaces windows-plattform-specific file separator \ with /

Throws:
IOException - if position of file is not relative to base

getJarFiles

public static File[] getJarFiles(String baseDir,
                                 String dirList)
                          throws IOException
Throws:
IOException

getStackTraceAsString

public static String getStackTraceAsString(Throwable ex)


Copyright © 2000-2006 Rapla Team. All Rights Reseserved.