API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.utils. JOTUtilities View Source
Author(s)
tcolar
Since
Version
Serial
Hierarchy
 Object
      JOTUtilities
Implements
Subclasses
Description
public class JOTUtilities
Collection of small utilities which aren't worth having their own class :-)
See also:   
Constructors
public JOTUtilities ()
Methods
Hide/Show inherited methods
publicstatic boolean checkEmail (String email)
  Validates wether an email address seem to be valid (ie: ~ aa@bb.cc)
publicstatic boolean checkFieldLength (String field, int minSize)
  Checks wether s string is at least minSize long
publicstatic void copyFile (File dest, File src) throws FileNotFoundException IOException
  copy a file ...
publicstatic void copyFolderContent (File newFolder, File oldFolder, boolean recurse) throws Exception
  recursively copy the content of oldfolder into a newfolder
publicstatic File createTempFile (String prefix, String path)
  Description of the Method
publicstatic void deleteFolder (File folder)
  Delete a folder recursively
publicstatic void deleteFolderContent (File root)
  Recursively delete all the content of a folder (but not the folder itself)
publicstatic String encodeCSVEntry (String s)
endode a cell of data into CVS format.
publicstatic String endWithForwardSlash (String str)
publicstatic String endWithSlash (String str)
  Return a folder path with the trailing slah
publicstatic String firstLine (String str)
  Description of the Method
publicstatic String formatDate (Date d, boolean sqlFormat)
  Formats a date into - a user friendly format: 01/19/1977 04:08 - an SQL format: 77-01-19 04:08
publicstatic String formatNumber (int nb, int length)
  Padds an umber with 0's to make it correct length
publicstatic String formatString (String str, int length)
  Fornat a string to a specific length by truncating or padding with spaces as needed.
publicstatic String getFileMd5 (File f) throws Exception
  Computes the MD5 hash of a file's content
publicstatic int getFolderSize (File folder)
  get a directory size (recursively)
publicstatic String getSHA1Hash (String input) throws Exception
  Computes an SHA1 hash as an Hex format string.
publicstatic String getShortClassname (Class clazz)
publicstatic File getStandardTmpDir ()
  Returns java standrad tmp dir (java.io.tmpdir)
publicstatic boolean isWindowsOS ()
publicstatic boolean isWithinFolder (File f, File folder)
  Checks if "f" is within "folder" hierarchy (recursively) ie: if folder is an ancestor of f.
publicstatic String lowerCase (String s)
publicstatic void moveFile (File dest, File src) throws FileNotFoundException IOException
  Move a filke to a new location Note that is does a copy then a delete, as actaully "moving" the file does not always work right in my experience
publicstatic void moveFolderContent (File newFolder, File oldFolder)
  Recursively moving all the content of oldfolder into newfolder It does a copy then delete rather than a real move
publicstatic String replaceAll (String src, String pattern, String replacement)
  Replace all occurence of "pattern" by "replacement" in the string "src" This does not use the "replaceAll()" method of the String class, which often leads to issues since it interprets some charcaters such as "$".
publicstatic void sendRedirect (HttpServletResponse res, String newLocation, boolean permanent, boolean encodeIt)
  The Standard java response.sendredirect tries to rebuild the full URL using the servlet path This will not work with java behind a proxy (since it will use the proxy path rather than vanity URL) So here we just send a simple (possibly relative) URL.
publicstatic String sizeIt (int i, int length)
  Pads a number with zeroes to make it requested length
publicstatic String sizeIt (String s, int length)
  Pads a string(number) with zeroes to make itt requested length
publicstatic File sortFolderListing (File files, int sortOrder)
  Sorts the file listing
publicstatic String unzip (String filename, String tmpdir, String retrieve) throws Exception
  Unzip a zip file in the given folder (recursively); Retrieve is use as this if retrieve is set to ".swf", the last file found ending by .swf will be returned.
publicstatic String upperCase (String s)
publicstatic String upperFirst (String s)
  Uppercase the first letter of a string (ie: name)
publicstatic void zipFolder (ZipOutputStream zos, String root, File folder) throws IOException
  Recursively zip the content of a folder into a stream / file
Fields
Hide/Show inherited fields
publicfinalstatic int SORT_BY_NAME_ASC = "1"
Sorting types for the sort method
publicfinalstatic int SORT_BY_NAME_DESC = "-1"
publicfinalstatic int SORT_BY_SIZE_ASC = "2"
publicfinalstatic int SORT_BY_SIZE_DESC = "-2"
publicfinalstatic int SORT_BY_TSTAMP_ASC = "3"
publicfinalstatic int SORT_BY_TSTAMP_DESC = "-3"
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar