org.apache.wicket.util.file
Class Files

java.lang.Object
  extended by org.apache.wicket.util.file.Files

public class Files
extends java.lang.Object

File utility methods.

Author:
Jonathan Locke

Method Summary
static java.lang.String basePath(java.lang.String path, java.lang.String extension)
          Strips off the given extension (probably returned from Files.extension()) from the path, yielding a base pathname.
static java.lang.String cleanupFilename(java.lang.String filename)
           Replaces commonly unsupported characters with '_'
static java.lang.String extension(java.lang.String path)
          Gets extension from path
static java.lang.String filename(java.lang.String path)
          Gets filename from path
static boolean remove(java.io.File file)
          Deletes a file, dealing with a particularly nasty bug on Windows.
static int writeTo(java.io.File file, java.io.InputStream input)
          Writes the given input stream to the given file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

basePath

public static java.lang.String basePath(java.lang.String path,
                                        java.lang.String extension)
Strips off the given extension (probably returned from Files.extension()) from the path, yielding a base pathname.

Parameters:
path - The path, possibly with an extension to strip
extension - The extension to strip, or null if no extension exists
Returns:
The path without any extension

extension

public static java.lang.String extension(java.lang.String path)
Gets extension from path

Parameters:
path - The path
Returns:
The extension, like "bmp" or "html", or null if none can be found

filename

public static java.lang.String filename(java.lang.String path)
Gets filename from path

Parameters:
path - The path
Returns:
The filename

remove

public static boolean remove(java.io.File file)
Deletes a file, dealing with a particularly nasty bug on Windows.

Parameters:
file - File to delete
Returns:
True if file was deleted

writeTo

public static final int writeTo(java.io.File file,
                                java.io.InputStream input)
                         throws java.io.IOException
Writes the given input stream to the given file

Parameters:
file - The file to write to
input - The input
Returns:
Number of bytes written
Throws:
java.io.IOException

cleanupFilename

public static final java.lang.String cleanupFilename(java.lang.String filename)

Replaces commonly unsupported characters with '_'

Parameters:
filename - to be cleaned
Returns:
cleaned filename


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.