public class IOUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DOWNLOAD_ERROR |
static int |
DOWNLOAD_OK |
static java.lang.String |
MIMETYPE_PLAINTEXT |
protected static org.apache.oro.text.regex.Pattern |
patternBlank1 |
protected static org.apache.oro.text.regex.Pattern |
patternBlank2 |
static java.lang.String |
REVISION |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
base64DecodeAndInflateString(java.lang.String str)
Inflates Base64 encoded string.
|
static boolean |
belongsToDirectory(java.io.File dir,
java.io.File untrustedFile)
Check that the specified file belongs to the specified directory or any of its subdirectory.
|
static boolean |
canWrite(java.io.File file,
boolean checkParent)
Tests whether the application can modify to the file denoted by
the given file.
|
static boolean |
checkFileSizeAndMtime(java.io.File file,
long size,
long mtime)
Returns true if the given file exists and has the given size and the given mtime.
|
static void |
closeQuietly(java.io.InputStream inputStream)
Close the given inputStream.
|
static void |
closeQuietly(java.io.OutputStream outputStream)
Close the given writer.
|
static void |
closeQuietly(java.io.Reader reader)
Close the given reader.
|
static void |
closeQuietly(java.io.Writer writer)
Close the given writer.
|
static void |
convertCharset(java.io.File file,
java.lang.String fromCS,
java.lang.String toCS)
Encode the given file with a given charset.
|
static int |
copy(java.io.InputStream input,
java.io.OutputStream output)
Copy bytes from an
InputStream to an
OutputStream . |
static void |
copy(java.io.InputStream input,
java.io.Writer output,
java.lang.String encoding)
Copy bytes from an
InputStream to chars on a
Writer using the specified character encoding, or UTF-8 if null. |
static void |
copy(java.io.Reader input,
java.io.OutputStream output,
java.lang.String encoding)
Copy chars from a
Reader to bytes on an
OutputStream using the specified character encoding, and
calling flush. |
static int |
copy(java.io.Reader input,
java.io.Writer output)
Copy chars from a
Reader to a Writer . |
static void |
copyFile(java.io.File f1,
java.io.File f2)
Copy f1 into f2 (mkdirs for f2)
|
static void |
copyFile(java.lang.String filename1,
java.lang.String filename2)
Copy filename1 into filename2 (mkdirs for filename2)
|
static java.io.File |
createTempDir()
Creates a new empty directory
|
static java.io.File |
createTempDir(java.lang.String name,
java.lang.String prefix,
java.io.File parentDir,
boolean clear)
Creates a new empty directory
|
static void |
deepCopy(java.io.File srcDir,
java.io.File tgtDir)
Perform a directory deep copy.
|
static void |
deepCopy(java.io.File srcDir,
java.io.File tgtDir,
boolean deleteEmptyFile)
Perform a directory deep copy.
|
static void |
deepCopy(java.io.File srcDir,
java.io.File tgtDir,
boolean deleteEmptyFile,
java.io.FileFilter filter)
Perform a directory deep copy.
|
static void |
deepDelete(java.io.File file)
Deletes a whole directory.
|
static void |
deepDelete(java.io.File file,
ActionListener listener)
Deletes a whole directory.
|
static void |
deepDeleteEmptyDirectories(java.io.File dir)
Delete recursively all enpty directories under a given directory.
|
static void |
deepDeleteEmptyDirectories(java.io.File dir,
java.io.FileFilter filter)
Delete recursively all enpty directories under a given directory.
|
static void |
deepDeleteEmptyDirectories(java.io.File dir,
java.io.FileFilter filter,
ActionListener listener)
Delete recursively all enpty directories under a given directory.
|
static java.util.List<java.io.File> |
deepListFiles(java.io.File dir,
java.io.FileFilter filter)
Return a list of files from the given directory and matching the
given filter.
|
static java.util.List<java.io.File> |
deepListFiles(java.io.File dir,
java.io.FileFilter filter,
boolean checkDir)
Return a list of files from the given directory and matching the
given filter.
|
static void |
deepListFiles(java.io.File file,
java.util.Set<java.io.File> fileSet,
java.util.Set<java.lang.String> blackSet)
Follow recursively a Path each File that are not
Blacklisted (ends with a String of the BlackListSet)
are added to the FileSet
Compare (convert \\ to /) but store File with \ or / depends of platform
|
static java.lang.String |
deflateAndBase64EncodeString(java.lang.String str)
Compresses (deflates) a string and Base64 encodes the result and
returns it as a string.
|
static int |
downloadFile(java.net.URL url,
java.io.File file,
long lastModified,
java.lang.String ticket)
Download the given URL
|
static byte[] |
emptyInputStream(java.io.DataInputStream dis)
Emptys an InputStream
|
static void |
forceDeepCopy(java.io.File srcDir,
java.io.File tgtDir,
boolean deleteEmptyFile,
java.io.FileFilter filter)
Perform a directory deep copy.
|
static java.lang.String |
getDownloadTicket(java.io.File file)
Get a download ticket for the given file
|
static java.lang.String |
getExtension(java.io.File file)
Returns the extension of the given file (without the leading "." char).
|
static java.lang.String |
getExtension(java.lang.String filename)
Returns the extension of the given file (without the leading "." char).
|
static java.io.InputStream |
getInputStream(java.net.HttpURLConnection httpConn)
Retrieve the input stream of the specified HttpURLConnection, decoded
appropriately if gzip was used.
|
static java.lang.String |
getMimeTypeFromMagicNumber(java.io.File file)
Gives the mime type of a file.
|
static java.lang.String |
getNewDirectory(java.io.File baseDir,
java.lang.String subDir,
long maxFilesPerDir)
Returns the relative path of directory to use for the new document to be created.
|
static java.lang.String |
getQualifiedName(java.io.File file)
This method return the name of a given file
it return string before last '.' of the filename.
|
static java.lang.String |
getQualifiedName(java.lang.String filename)
This method return the name of a given file name
it return string before last '.' of the filename.
|
static java.lang.String |
getRelativePath(java.io.File dir,
java.io.File file)
Return the relative path of the specified file in the specified directory.
|
static java.io.File |
getTempDir(java.lang.String name,
java.lang.String prefix,
java.io.File parentDir)
Returns An abstract pathname denoting an empty directory (this directory is not created).
|
static java.io.InputStream |
getZipFileStream(java.lang.String fileName,
java.io.File zipFile)
Returns an InputStream on the File representing by the given fileName
in the given zip file.
|
static java.io.InputStream |
getZipFileStream(java.lang.String fileName,
java.io.File zipFile,
boolean regexp) |
static boolean |
goToLine(java.io.InputStream in,
long line)
Move the position of the given InputStream to the given line.
|
static boolean |
goToLine(java.io.RandomAccessFile raf,
long line)
Move the position of the given InputStream to the given line.
|
static boolean |
isParent(java.io.File parent,
java.io.File child)
Check if a File is a child of an other File recursively.
|
static boolean |
isSameContent(java.io.File f1,
java.io.File f2)
Returns true if the given files have the same content.
|
static boolean |
moveFile(java.io.File f1,
java.io.File f2)
Move f1 into f2 (mkdirs for f2).
|
static java.net.HttpURLConnection |
openConnection(java.net.URL url,
boolean doOutput,
boolean doInput,
java.lang.String method)
Open a new HttpURLConnection for the specified url
|
static java.lang.String[] |
readList(java.io.Reader reader)
Returns all the lines read on a given Reader.
|
static void |
removeBlankLines(java.lang.String filename,
boolean trim)
Remove all blank lines of a file.
|
static void |
searchAndReplace(java.io.File file,
java.util.Map<java.lang.String,java.lang.String> map)
Execute a map of regular expression on a given file content.
|
static void |
searchAndReplace(java.io.File file,
java.lang.String[] search,
java.lang.String[] replace)
Execute an array of regular expression on a given file content.
|
static java.lang.String |
substringFile(java.io.File parentFile,
java.io.File childFile)
If Parent is parent of child then we return
the substraction: childPath - parentPath.
|
static java.lang.String[] |
tail(java.io.File file,
int size,
boolean skipBlank,
java.lang.String encoding)
Returns the last lines of a file.
|
static java.io.File |
translateFile(java.io.File file,
java.io.File srcDir,
java.io.File tgtDir)
Returns the translated path of a given file which belongs to a
given source directory into a target directory.
|
static void |
unzip(java.io.File file,
java.io.File dir)
Unzip a file
|
static void |
unzip(java.io.File file,
java.io.File dir,
java.io.FileFilter filter)
Unzip a file
|
static void |
unzip(java.lang.String filename,
java.lang.String tgtDirname)
Unzip a file
|
static void |
unzip(java.lang.String filename,
java.lang.String tgtDirname,
java.io.FileFilter filter)
Unzip a file
Adapted from:
Working with Java Archive APIs
Lawrence Rodrigues
Java Report On-line
http://archive.javareport.com/9808/html/features/archive/9806/rodrigues.shtml
|
static void |
writeArray(java.io.Writer writer,
java.lang.String[] array)
Writes an array of String on a given Writer.
|
static void |
writeEnumeration(java.io.Writer writer,
java.util.Enumeration<?> enu)
Writes an enumeration of object on a given Writer.
|
static void |
writeIterator(java.io.Writer writer,
java.util.Iterator<?> it)
Writes an iteration of object on a given Writer.
|
static void |
zip(java.io.File[] files,
java.lang.String destFile,
int[] prefixLength,
java.io.FileFilter[] filters)
Zip an array of files or directories into a file.
|
static void |
zip(java.io.File file,
java.lang.String zipFile,
int prefixLength,
java.io.FileFilter filter) |
static java.lang.String |
zip(java.lang.String filename,
boolean isParentDirRemoved)
Zip a file or a whole directory.
|
static void |
zip(java.lang.String filename,
java.lang.String zipFile,
boolean isParentDirRemoved)
Zip a file or a whole directory
|
static void |
zipWriter(java.io.File file,
java.util.zip.ZipOutputStream zos,
int prefixLength,
java.io.FileFilter filter)
Zip all files of a directory that are accepted by the given FileFilter.
|
public static final java.lang.String REVISION
public static int DOWNLOAD_ERROR
public static int DOWNLOAD_OK
protected static org.apache.oro.text.regex.Pattern patternBlank1
protected static org.apache.oro.text.regex.Pattern patternBlank2
public static final java.lang.String MIMETYPE_PLAINTEXT
public static java.lang.String[] readList(java.io.Reader reader) throws java.io.IOException
reader
- the readerjava.io.IOException
public static void deepListFiles(java.io.File file, java.util.Set<java.io.File> fileSet, java.util.Set<java.lang.String> blackSet)
file
- the directory to followfileSet
- a Set where to put all filesblackSet
- a Set of String to identify Files that ends with that Stringpublic static java.util.List<java.io.File> deepListFiles(java.io.File dir, java.io.FileFilter filter)
dir
- the directory to explorefilter
- the FileFilter to use (may be null)deepListFiles(File, FileFilter, boolean)
public static java.util.List<java.io.File> deepListFiles(java.io.File dir, java.io.FileFilter filter, boolean checkDir)
dir
- the directory to explorefilter
- the FileFilter to use (may be null)checkDir
- if true the directories that do not match the filter are skipped.public static java.lang.String substringFile(java.io.File parentFile, java.io.File childFile)
parentFile
- the parent FilechildFile
- the child Filepublic static void writeArray(java.io.Writer writer, java.lang.String[] array) throws java.io.IOException
writer
- the writerarray
- the array of String to writejava.io.IOException
public static void writeEnumeration(java.io.Writer writer, java.util.Enumeration<?> enu) throws java.io.IOException
writer
- the writerenu
- the enumerationjava.io.IOException
public static void writeIterator(java.io.Writer writer, java.util.Iterator<?> it) throws java.io.IOException
writer
- the writerit
- the iteratorjava.io.IOException
public static void unzip(java.io.File file, java.io.File dir) throws java.io.IOException
file
- the file to unzipdir
- the target directoryjava.io.IOException
unzip(String, String, FileFilter)
public static void unzip(java.io.File file, java.io.File dir, java.io.FileFilter filter) throws java.io.IOException
file
- the file to unzipdir
- the target directoryfilter
- an optional FileFilter to filter the file to be extracted.java.io.IOException
unzip(String, String, FileFilter)
public static void unzip(java.lang.String filename, java.lang.String tgtDirname) throws java.io.IOException
filename
- the name of the file to unziptgtDirname
- the name of the target directoryjava.io.IOException
unzip(String, String, FileFilter)
public static void unzip(java.lang.String filename, java.lang.String tgtDirname, java.io.FileFilter filter) throws java.io.IOException
filename
- the name of the file to unziptgtDirname
- the name of the target directoryfilter
- an optional FileFilter to filter the file to be extracted.java.io.IOException
public static java.lang.String zip(java.lang.String filename, boolean isParentDirRemoved) throws java.io.IOException
filename
- the name of file or directory to zipisParentDirRemoved
- true if the parent path prefix of the
filename must be removed in the zip file (eg: foo/* instead of
a/b/c/foo/* when zipping directory "a/b/c/foo/")java.io.IOException
public static void zip(java.lang.String filename, java.lang.String zipFile, boolean isParentDirRemoved) throws java.io.IOException
filename
- the name of file or directory to zipzipFile
- the name of the zip file to produceisParentDirRemoved
- true if the parent path prefix of the
filename must be removed in the zip file (eg: foo/* instead of
a/b/c/foo/* when zipping directory "a/b/c/foo/")java.io.IOException
public static void zip(java.io.File file, java.lang.String zipFile, int prefixLength, java.io.FileFilter filter) throws java.io.IOException
java.io.IOException
public static void zip(java.io.File[] files, java.lang.String destFile, int[] prefixLength, java.io.FileFilter[] filters) throws java.io.IOException
files
- the array of files or directories to be zippeddestFile
- the path of the destination zip fileprefixLength
- an array of prefix size to be used for each element of the files array.filters
- array of FileFilters to be used for filtering files.java.io.IOException
public static void zipWriter(java.io.File file, java.util.zip.ZipOutputStream zos, int prefixLength, java.io.FileFilter filter) throws java.io.IOException
file
- the file or directory to be zippedzos
- the ZipOutputStream into which the file has to be addedprefixLength
- the size of the prefixfilter
- the filter to be usedjava.io.IOException
public static java.io.InputStream getZipFileStream(java.lang.String fileName, java.io.File zipFile)
fileName
- the file name of the file to seekzipFile
- File reprenst the zippublic static java.io.InputStream getZipFileStream(java.lang.String fileName, java.io.File zipFile, boolean regexp)
public static java.lang.String deflateAndBase64EncodeString(java.lang.String str) throws java.io.IOException
str
- The string to compress and encode.java.io.IOException
- Will probably not happen, maybe if there is a bug in the
code or we run out of memory.public static java.lang.String base64DecodeAndInflateString(java.lang.String str) throws java.util.zip.DataFormatException, java.io.UnsupportedEncodingException
str
- String should be compressed and Base64 encoded data.java.util.zip.DataFormatException
- on bad input.java.io.UnsupportedEncodingException
public static void deepDelete(java.io.File file)
file
- the directory to destroypublic static void deepDelete(java.io.File file, ActionListener listener)
file
- the directory to destroylistener
- a custom ActionListener used to perform custom actino during recursive callspublic static void deepDeleteEmptyDirectories(java.io.File dir)
dir
- the directory to destroypublic static void deepDeleteEmptyDirectories(java.io.File dir, java.io.FileFilter filter)
dir
- the directory to destroyfilter
- files to ignore and removepublic static void deepDeleteEmptyDirectories(java.io.File dir, java.io.FileFilter filter, ActionListener listener)
dir
- the directory to destroyfilter
- FileFilter used to find files to be deleted before checking whether the directory is emptylistener
- to perform action during recursive callspublic static java.io.File translateFile(java.io.File file, java.io.File srcDir, java.io.File tgtDir)
file
- the file to translatesrcDir
- the source directorytgtDir
- the target directorypublic static void searchAndReplace(java.io.File file, java.lang.String[] search, java.lang.String[] replace)
file
- the file to parsesearch
- an array of regular expression to matchreplace
- ann array of regular expression to replacepublic static void searchAndReplace(java.io.File file, java.util.Map<java.lang.String,java.lang.String> map)
file
- the file to parsemap
- a map with regexp as key and substitute string as value.public static void deepCopy(java.io.File srcDir, java.io.File tgtDir, boolean deleteEmptyFile, java.io.FileFilter filter) throws java.io.IOException
srcDir
- the source directory to copytgtDir
- the target directorydeleteEmptyFile
- if true delete empty files.filter
- the filter to be used (may be null)java.io.IOException
- if it append for one file.public static void forceDeepCopy(java.io.File srcDir, java.io.File tgtDir, boolean deleteEmptyFile, java.io.FileFilter filter)
srcDir
- the source directory to copytgtDir
- the target directorydeleteEmptyFile
- if true delete empty files.filter
- the filter to be used (may be null)public static void deepCopy(java.io.File srcDir, java.io.File tgtDir, boolean deleteEmptyFile) throws java.io.IOException
srcDir
- the source directory to copytgtDir
- the target directorydeleteEmptyFile
- if true delete empty files.java.io.IOException
public static void deepCopy(java.io.File srcDir, java.io.File tgtDir) throws java.io.IOException
srcDir
- the source directory to copytgtDir
- the target directoryjava.io.IOException
public static boolean isParent(java.io.File parent, java.io.File child)
parent
- the parent filechild
- the child filepublic static void copyFile(java.lang.String filename1, java.lang.String filename2) throws java.io.IOException
filename1
- the source filefilename2
- the target filejava.io.IOException
public static void copyFile(java.io.File f1, java.io.File f2) throws java.io.IOException
f1
- the source filef2
- the target filejava.io.IOException
public static boolean moveFile(java.io.File f1, java.io.File f2)
f1
- the source filef2
- the target filetrue
if and only if the moving succeeded; false
otherwise.public static byte[] emptyInputStream(java.io.DataInputStream dis)
dis
- the DataInputStream to emptypublic static void removeBlankLines(java.lang.String filename, boolean trim) throws java.io.IOException
filename
- the name of the file from which to remove blank lines.trim
- If false, remove only blank lines without space (i.e. matching /^$/)
otherwise remove blank lines and space lines (i.e. matching /^\s*$/).java.io.IOException
public static java.io.File createTempDir()
public static java.io.File createTempDir(java.lang.String name, java.lang.String prefix, java.io.File parentDir, boolean clear)
name
- The name of the directory to create. If null,
generate a name based on prefix and current time.prefix
- The prefix string to be used in generating the file's nameparentDir
- The parent directory in which the directory is to
be created, or null if the default temporary-file directory is to
be usedclear
- if true and if this directory already exists the content is deep deletedpublic static java.io.File getTempDir(java.lang.String name, java.lang.String prefix, java.io.File parentDir)
name
- The name of the directory to create. If null,
generate a name.prefix
- The prefix string to be used in generating the file's nameparentDir
- The parent directory in which the directory is to
be created, or null if the default temporary-file directory is to
be usedpublic static boolean canWrite(java.io.File file, boolean checkParent)
file
- the file to testcheckParent
- true if the parent must checkedpublic static java.lang.String getRelativePath(java.io.File dir, java.io.File file)
The returned path is platform independent :
URI
.
Examples :
IOUtil.getRelativePath(new File("/foo/"), new File("/foo/bar/out.txt")); => "bar/out.txt" IOUtil.getRelativePath(new File("c:\\foo"), new File("c:\\foo\\bar\\out.txt")); => "bar/out.txt" IOUtil.getRelativePath(new File("/dir1/"), new File("/dir2/file.txt")); => null IOUtil.getRelativePath(new File("/foo/"), new File("/foo/bar baz/out.txt")); => "bar%20baz/out.txt"
dir
- the directoryfile
- the filepublic static boolean belongsToDirectory(java.io.File dir, java.io.File untrustedFile)
Exemple :
File dir = new File("/some/directory/"); File fileOk = new File("/some/directory/subdirectory/ok.txt"); File fileKo = new File("/etc/passwd"); assertTrue(IOUtil.belongsToDirectory(dir, fileOk)); assertFalse(IOUtil.belongsToDirectory(dir, fileKo));
dir
- the directoryuntrustedFile
- the file to checkjava.lang.IllegalArgumentException
- if any of the parameter is nullpublic static boolean goToLine(java.io.InputStream in, long line) throws java.io.IOException
in
- the InputStream to move the position.line
- the line to be reachedjava.io.IOException
public static boolean goToLine(java.io.RandomAccessFile raf, long line) throws java.io.IOException
raf
- the RandomAccessFile to move the position.line
- the line to be reachedjava.io.IOException
public static java.lang.String getExtension(java.io.File file)
foo/bar.XML
it returns xml
.file
- the file to get the extensionpublic static java.lang.String getExtension(java.lang.String filename)
foo/bar.xml
it returns xml
.filename
- the filename to get the extensiongetExtension(File)
public static java.lang.String getQualifiedName(java.io.File file)
file
- the File of which to retrieve qualified namepublic static java.lang.String getQualifiedName(java.lang.String filename)
filename
- the file namegetQualifiedName(File)
public static void convertCharset(java.io.File file, java.lang.String fromCS, java.lang.String toCS) throws java.io.IOException
file
- the file to be encodedfromCS
- the original charset of the filetoCS
- the new charset of the filejava.io.IOException
public static int copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException
InputStream
to an
OutputStream
.
This method buffers the input internally, so there is no need to use a
BufferedInputStream
.
input
- the InputStream
to read fromoutput
- the OutputStream
to write tojava.lang.NullPointerException
- if the input or output is nulljava.io.IOException
- if an I/O error occurspublic static void copy(java.io.InputStream input, java.io.Writer output, java.lang.String encoding) throws java.io.IOException
InputStream
to chars on a
Writer
using the specified character encoding, or UTF-8 if null.
This method buffers the input internally, so there is no need to use a
BufferedInputStream
.
Character encoding names can be found at IANA.
This method uses InputStreamReader
.
input
- the InputStream
to read fromoutput
- the Writer
to write toencoding
- the encoding to use, null means platform defaultjava.lang.NullPointerException
- if the input or output is nulljava.io.IOException
- if an I/O error occurspublic static int copy(java.io.Reader input, java.io.Writer output) throws java.io.IOException
Reader
to a Writer
.
This method buffers the input internally, so there is no need to use a
BufferedReader
.
input
- the Reader
to read fromoutput
- the Writer
to write tojava.lang.NullPointerException
- if the input or output is nulljava.io.IOException
- if an I/O error occurspublic static void copy(java.io.Reader input, java.io.OutputStream output, java.lang.String encoding) throws java.io.IOException
Reader
to bytes on an
OutputStream
using the specified character encoding, and
calling flush.
This method buffers the input internally, so there is no need to use a
BufferedReader
.
Character encoding names can be found at IANA.
Due to the implementation of OutputStreamWriter, this method performs a flush.
This method uses OutputStreamWriter
.
input
- the Reader
to read fromoutput
- the OutputStream
to write toencoding
- the encoding to use, null means platform defaultjava.lang.NullPointerException
- if the input or output is nulljava.io.IOException
- if an I/O error occurspublic static void closeQuietly(java.io.Reader reader)
reader
- public static void closeQuietly(java.io.Writer writer)
writer
- public static void closeQuietly(java.io.InputStream inputStream)
inputStream
- public static void closeQuietly(java.io.OutputStream outputStream)
outputStream
- public static boolean isSameContent(java.io.File f1, java.io.File f2)
f1
- the first file to be comparedf2
- the second file to be comparedpublic static java.lang.String getNewDirectory(java.io.File baseDir, java.lang.String subDir, long maxFilesPerDir)
baseDir
- the base directory (eg /usr/local/tomcat/webapps/jcms/)subDir
- an optionnal sub directory, may be null (eg upload/docs/image/gif/)maxFilesPerDir
- how many files are allowed per directory.public static java.lang.String[] tail(java.io.File file, int size, boolean skipBlank, java.lang.String encoding) throws java.io.IOException
file
- the filesize
- how many lines to returnsskipBlank
- if true skip the blank linesencoding
- the file encodingjava.io.IOException
public static java.lang.String getDownloadTicket(java.io.File file)
file
- the file to get a ticket forpublic static int downloadFile(java.net.URL url, java.io.File file, long lastModified, java.lang.String ticket)
url
- the URL to downloadfile
- the target filelastModified
- if > 0, the last lastModified date of the file will be set to this valueticket
- the ticket to be used for the downloadpublic static java.net.HttpURLConnection openConnection(java.net.URL url, boolean doOutput, boolean doInput, java.lang.String method) throws java.io.IOException
url
- the URL for which HttpURLConnection is openeddoOutput
- see URLConnection.setDoOutput(boolean)
doInput
- see URLConnection.setDoInput(boolean)
method
- see HttpURLConnection.setRequestMethod(String)
java.io.IOException
public static java.io.InputStream getInputStream(java.net.HttpURLConnection httpConn) throws java.io.IOException
httpConn
- the HttpUrlConnection being usedjava.io.IOException
public static boolean checkFileSizeAndMtime(java.io.File file, long size, long mtime)
file
- the filesize
- the excepted sizemtime
- the expected mtimepublic static java.lang.String getMimeTypeFromMagicNumber(java.io.File file)
UtfUtil
MagicNumber
MagicMimeTypeIdentifier
MagicString
MagicNumber
file
- the file to testCopyright © 2001-2010 Jalios SA. All Rights Reserved.