java.lang.Object | |
↳ | com.microstrategy.web.app.utils.FileUtils |
Title: FileUtils class
Description: Includes generic functions to use when accessing files and directories. All
methods are Static
so no class instance is required to access them.
Copyright: Copyright (c) 2001
Company: MicroStrategy, Inc.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FileUtils() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static String |
cleanFileName(String s)
Produces a clean form of a file name (typically from an object name, such
as the name of a report).
| ||||||||||
static boolean |
fileExists(String fileName)
Verifies if the file can be accessed.
| ||||||||||
static long |
fileSize(String fileName)
Given the file path and name, searches for the file and returns its size
| ||||||||||
static FileContentsObjectList |
getObjectFileContents(String fileName)
Opens the indicated file.
| ||||||||||
static String |
getTextFileContents(String fileName, boolean newLine)
Obtains the contents of the requested file
| ||||||||||
static String |
getTextFileContents(String fileName)
Opens the indicated file.
| ||||||||||
static String |
getTextFileContents(String fileName, boolean newLine, String encoding, String newLineChar)
Obtains the contents of the requested file
| ||||||||||
static String |
getTextFileContents(String fileName, boolean newLine, String encoding)
Obtains the contents of the requested file
| ||||||||||
static String |
getTextFileContentsWithoutBom(String fileName, boolean newLine)
Obtains the contents of the requested file, if encoded in UTF-8, delete the BOM
| ||||||||||
static void |
saveObjectFileContents(String fileName, FileContentsObjectList oInfo, boolean append)
Writes to the indicated file.
| ||||||||||
static void |
setObjectFileContents(String fileName, FileContentsObjectList oInfo, boolean append)
Saves the oInfo collection into the indicated file.
| ||||||||||
static void |
setObjectFileContents(String fileName, FileContentsObjectList oInfo)
Saves the collection sent as parameter into the indicated file.
| ||||||||||
static void |
setTextFileContents(String fileName, String fileContents, boolean append)
Opens the requested file as a new one (overwrite) or appending the contents if requested.
| ||||||||||
static void |
setTextFileContents(String fileName, String fileContents, boolean changeLine, boolean append)
Opens the requested file as a new one (overwrite) or appending the contents if requested.
| ||||||||||
static void |
setTextFileContents(String fileName, String fileContents)
Saves the string sent as parameter into the indicated file.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Produces a clean form of a file name (typically from an object name, such as the name of a report). This is really just a method to replace a predefined set of characters ('%', '.', '/', '\\', ':', '*', '?', '"', '<', '>', '|', ',') in a string with another character ('_').
s | This is the incoming string that may have special characters in it. |
---|
String
with all special characters replaced.
Verifies if the file can be accessed.
fileName | Name of the file to search for. |
---|
true
if the file is found, otherwise returns false
Given the file path and name, searches for the file and returns its size
fileName | path and file name to search for |
---|
Opens the indicated file. Reads its contents retrieving them as objects.
fileName | Name of the file from where the contents are to be extracted. |
---|
Object
that includes all the information found on the file.WebAppException | if any error happens while accessing the file. |
---|
Obtains the contents of the requested file
fileName | name of the file to search for |
---|---|
newLine | if it should insert a change of line each time it finds one on the file |
WebAppException | if an error happened while reading the file. |
---|
Opens the indicated file. Starts reading it line by line and storing its content
on a buffer. When the end of the file is reached, the buffer is copied into a String
which is the output of this method.
Handles java.io.FileNotFoundException
if the file requested is not found.
Catches Exception
if any other error happens while reading the file contents.
fileName | Name of the file from where the contents are to be extracted. |
---|
String
with the file contents on it (including line breaks)WebAppException | if any error happens while accessing the file. |
---|
Obtains the contents of the requested file
fileName | name of the file to search for |
---|---|
newLine | if it should insert a change of line each time it finds one on the file |
encoding | encoding type |
newLineChar | the new line separator |
WebAppException | if an error happened while reading the file. |
---|
Obtains the contents of the requested file
fileName | name of the file to search for |
---|---|
newLine | if it should insert a change of line each time it finds one on the file |
encoding | encoding type |
WebAppException | if an error happened while reading the file. |
---|
Obtains the contents of the requested file, if encoded in UTF-8, delete the BOM
fileName | name of the file to search for |
---|---|
newLine | if it should insert a change of line each time it finds one on the file |
WebAppException | if an error happened while reading the file. |
---|
Writes to the indicated file. Receives a FileContentsObjectList collection where all the information to be saved is found. It parses each one of the elements of the list and writes it to the file.
fileName | Name of the file from where the contents are to be extracted. |
---|---|
oInfo | FileContentsObjectList collection with the contents
to be written to the file |
append | Boolean indicating if the file should be appended or overwritten * |
WebAppException | if any error happens while accessing the file. |
---|
Saves the oInfo collection into the indicated file. By default it overwrites the file if already existing. Used as interface for saveObjectFileContents.
fileName | Name of the file where to write. |
---|---|
oInfo | FileContentsObjectList instance to write back to the file |
append | Boolean indicating if the file should be appended or overwritten |
WebAppException | if any error happens while accessing the file. |
---|
Saves the collection sent as parameter into the indicated file. By default it overwrites the file if already existing. Used as interface for saveObjectFileContents.
fileName | Name of the file where to write. |
---|---|
oInfo | FileContentsObjectList instance to write back to the file |
WebAppException | if any error happens while accessing the file. |
---|
Opens the requested file as a new one (overwrite) or appending the contents if requested. Writes the string and closes the file. By default changes line after inserting contents.
fileName | Name of the file where to write. |
---|---|
fileContents | String to write to the file. |
append | Boolean indicating if the file is to be appended or overwritten |
WebAppException | if any error happens while accessing the file. |
---|
Opens the requested file as a new one (overwrite) or appending the contents if requested. Writes the string and closes the file.
fileName | Name of the file where to write. |
---|---|
fileContents | String to write to the file. |
changeLine | Boolean indicating if a change of line should be inserted after the contents or not |
append | Boolean indicating if the file is to be appended or overwritten |
WebAppException | if any error happens while accessing the file. |
---|
Saves the string sent as parameter into the indicated file. By default it overwrites the file if already existing. Used as interface for saveTextFileContents. By default appends an end of line after inserting the contents.
fileName | Name of the file where to write. |
---|---|
fileContents | String to write to the file |
WebAppException | if any error happens while accessing the file. |
---|