phenote.util
Class FileUtil

java.lang.Object
  extended by phenote.util.FileUtil

public class FileUtil
extends java.lang.Object


Field Summary
static java.lang.String DASH
           
static java.lang.String DOT
           
static java.lang.String FILE_SEPARATOR
           
static java.lang.String UNDERSCORE
           
 
Constructor Summary
FileUtil()
           
 
Method Summary
static java.io.File archiveFile(java.io.File file, java.io.File archiveDirectory)
          This method moves (renames) a given file into an archive directory.
static java.io.File archiveFile(java.io.File file, java.lang.String archiveFolderPath, java.lang.String archiveFolderName)
          This method moves (renames) a given file into an archive directory.
static boolean copyFile(java.net.URL fromUrl, java.io.File toFile)
          some content from @link http://www.java2s.com/Code/Java/File-Input-Output/CopyfilesusingJavaIOAPI.htm
static boolean copyFileIntoArchive(java.io.File file, java.io.File archiveFile)
          Copy one file into another file.
static void copyReposToLocal(java.net.URL reposUrl, java.net.URL localUrl)
          local url may be from distrib/jar dir, but needs to be set to .phenote/obo-files dir as thats where the user cache is
static void copyUrlToFile(java.net.URL configUrl, java.io.File myPhenote)
          Used by Config
static java.net.URL findFile(java.lang.String fileName)
          Look for file in current directory (.) and jar file throws OntologyException if file not found - wraps FileNFEx
static java.net.URL findUrl(java.lang.String filename)
          split into findMaster?ConfigUrl & findOboUrl!!!
static int getBufferSize(java.net.URLConnection urlConnection)
          Should merge with getFileSize and getRemoteFileSize
static java.io.File getDotPhenoteConfDir()
           
static java.io.File getDotPhenoteDir()
          if ~/.phenote doesnt exist yet its created
static java.io.File getDotPhenoteOboDir()
           
static java.lang.String getFileSize(java.net.URL url)
           
static java.io.InputStream getInputStreamWithOrWithoutProxy(java.net.URL url)
           
static java.lang.String getLastModifiedDate(java.net.URL localUrl)
           
static java.lang.String getNameOfFile(java.lang.String path)
           
static java.lang.String getNameOfFile(java.net.URL urlFile)
          get actual name of file sans path
static java.lang.String getPureFileName(java.lang.String filename)
          Strip off all the path information from a file name.
static java.net.URLConnection getURLConnectionWithOrWithoutProxy(java.net.URL url)
           
static void purgeArchiveDirectory(java.io.File archiveDirectory, long purgeTime)
          Purge an archive directory for files that are older than the purge time.
static boolean urlExists(java.net.URL u)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SEPARATOR

public static final java.lang.String FILE_SEPARATOR

DASH

public static final java.lang.String DASH
See Also:
Constant Field Values

UNDERSCORE

public static final java.lang.String UNDERSCORE
See Also:
Constant Field Values

DOT

public static final java.lang.String DOT
See Also:
Constant Field Values
Constructor Detail

FileUtil

public FileUtil()
Method Detail

getDotPhenoteDir

public static java.io.File getDotPhenoteDir()
if ~/.phenote doesnt exist yet its created


getDotPhenoteOboDir

public static java.io.File getDotPhenoteOboDir()

getDotPhenoteConfDir

public static java.io.File getDotPhenoteConfDir()

getNameOfFile

public static java.lang.String getNameOfFile(java.net.URL urlFile)
get actual name of file sans path


getNameOfFile

public static java.lang.String getNameOfFile(java.lang.String path)

findUrl

public static java.net.URL findUrl(java.lang.String filename)
                            throws java.io.FileNotFoundException
split into findMaster?ConfigUrl & findOboUrl!!!

Throws:
java.io.FileNotFoundException

urlExists

public static boolean urlExists(java.net.URL u)

archiveFile

public static java.io.File archiveFile(java.io.File file,
                                       java.lang.String archiveFolderPath,
                                       java.lang.String archiveFolderName)
This method moves (renames) a given file into an archive directory. The file name is changed to include a time stamp.

Parameters:
file -
archiveFolderPath -
archiveFolderName -

archiveFile

public static java.io.File archiveFile(java.io.File file,
                                       java.io.File archiveDirectory)
This method moves (renames) a given file into an archive directory. The file name is changed to include a time stamp: original file name: archived file name: The archive file is returned. The original file is removed. The archive directory is created if it does not exist.

Parameters:
file - file that should be archived
archiveDirectory -
Returns:
File archive file

copyFileIntoArchive

public static boolean copyFileIntoArchive(java.io.File file,
                                          java.io.File archiveFile)
Copy one file into another file.

Parameters:
file -
archiveFile -

copyFile

public static boolean copyFile(java.net.URL fromUrl,
                               java.io.File toFile)
                        throws java.io.IOException
some content from @link http://www.java2s.com/Code/Java/File-Input-Output/CopyfilesusingJavaIOAPI.htm

Throws:
java.io.IOException

purgeArchiveDirectory

public static void purgeArchiveDirectory(java.io.File archiveDirectory,
                                         long purgeTime)
Purge an archive directory for files that are older than the purge time.

Parameters:
archiveDirectory -
purgeTime - in milliseconds

getPureFileName

public static java.lang.String getPureFileName(java.lang.String filename)
Strip off all the path information from a file name.

Parameters:
filename -

getLastModifiedDate

public static java.lang.String getLastModifiedDate(java.net.URL localUrl)

getFileSize

public static java.lang.String getFileSize(java.net.URL url)

getBufferSize

public static int getBufferSize(java.net.URLConnection urlConnection)
Should merge with getFileSize and getRemoteFileSize


copyReposToLocal

public static void copyReposToLocal(java.net.URL reposUrl,
                                    java.net.URL localUrl)
                             throws OntologyException
local url may be from distrib/jar dir, but needs to be set to .phenote/obo-files dir as thats where the user cache is

Throws:
OntologyException

getInputStreamWithOrWithoutProxy

public static java.io.InputStream getInputStreamWithOrWithoutProxy(java.net.URL url)
                                                            throws java.io.IOException
Throws:
java.io.IOException

getURLConnectionWithOrWithoutProxy

public static java.net.URLConnection getURLConnectionWithOrWithoutProxy(java.net.URL url)
                                                                 throws java.io.IOException
Throws:
java.io.IOException

findFile

public static java.net.URL findFile(java.lang.String fileName)
                             throws OntologyException
Look for file in current directory (.) and jar file throws OntologyException if file not found - wraps FileNFEx

Throws:
OntologyException

copyUrlToFile

public static void copyUrlToFile(java.net.URL configUrl,
                                 java.io.File myPhenote)
                          throws java.io.IOException
Used by Config

Throws:
java.io.IOException