RichFaces Photoalbum 4.3.5.Final

org.richfaces.photoalbum.util
Class FileManipulation

java.lang.Object
  extended by org.richfaces.photoalbum.util.FileManipulation

public class FileManipulation
extends Object

Utility class for operations with file-system


Constructor Summary
FileManipulation()
           
 
Method Summary
static void addDirectory(File directory)
          Utility method for creation of directory
static BufferedImage bitmapToImage(InputStream is, String format)
          Utility method to read image from disk and transform image to BufferedImage object
static void copyDirectory(File srcDir, File dstDir)
          Utility method for copying directory
static void copyFile(File srcFile, File destFile)
          Utility method for copying file
static boolean deleteDirectory(File dir, boolean isInitialDelete)
          Utility method for delete directory
static void deleteFile(File file)
          Utility method for delete file
static BufferedImage getScaledInstance(BufferedImage img, int targetWidth, int targetHeight, Object hint, boolean higherQuality)
          Convenience method that returns a scaled instance of the provided BufferedImage.
static void imageToBitmap(BufferedImage image, String data, String format)
          Utility method to write BufferedImage object to disk
static String joinFiles(String... files)
          Utility method for concatenation names of collection of files
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManipulation

public FileManipulation()
Method Detail

copyFile

public static void copyFile(File srcFile,
                            File destFile)
                     throws IOException
Utility method for copying file

Parameters:
srcFile - - source file
destFile - - destination file
Throws:
IOException

copyDirectory

public static void copyDirectory(File srcDir,
                                 File dstDir)
                          throws IOException
Utility method for copying directory

Parameters:
srcDir - - source directory
dstDir - - destination directory
Throws:
IOException

deleteDirectory

public static boolean deleteDirectory(File dir,
                                      boolean isInitialDelete)
Utility method for delete directory

Parameters:
dir - - directory to delete
isInitialDelete - - determine if the deleting process running at startup or on destroy of application
Returns:
true if directory succesfully deleted

joinFiles

public static String joinFiles(String... files)
Utility method for concatenation names of collection of files

Parameters:
files - - array of strings to concatenate
Returns:
concatenated string

deleteFile

public static void deleteFile(File file)
Utility method for delete file

Parameters:
file - - file to delete

bitmapToImage

public static BufferedImage bitmapToImage(InputStream is,
                                          String format)
                                   throws IOException
Utility method to read image from disk and transform image to BufferedImage object

Parameters:
data - - relative path to the image
format - - file prefix of the image
Returns:
BufferedImage representation of the image
Throws:
IOException

imageToBitmap

public static void imageToBitmap(BufferedImage image,
                                 String data,
                                 String format)
                          throws IOException
Utility method to write BufferedImage object to disk

Parameters:
image - - BufferedImage object to save.
data - - relative path to the image
format - - file prefix of the image
Throws:
IOException

getScaledInstance

public static BufferedImage getScaledInstance(BufferedImage img,
                                              int targetWidth,
                                              int targetHeight,
                                              Object hint,
                                              boolean higherQuality)
Convenience method that returns a scaled instance of the provided BufferedImage.

Parameters:
img - the original image to be scaled
targetWidth - the desired width of the scaled instance, in pixels
targetHeight - the desired height of the scaled instance, in pixels
hint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)
higherQuality - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, where targetWidth or targetHeight is smaller than the original dimensions, and generally only when the BILINEAR hint is specified)
Returns:
a scaled version of the original BufferedImage

addDirectory

public static void addDirectory(File directory)
Utility method for creation of directory

Parameters:
directory - - directory to create

RichFaces Photoalbum 4.3.5.Final

Copyright © 2014 JBoss by Red Hat. All Rights Reserved.