Package de.mid.innovator.m2msdk.util
Class FileAccess
java.lang.Object
de.mid.innovator.m2msdk.util.FileAccess
Class reading and writing a file. It can access files from file system or
from class path. It reads files from absolute paths or relative to the
arguments file. It can retrieve the content of a file either as string, as
stream or as document.
- Version:
- 10.1.1
- Author:
- jmback
-
Constructor Summary
ConstructorsConstructorDescriptionFileAccess(SessionInterface iSession, File file) Construct a file reader for a file name.FileAccess(SessionInterface iSession, String iFilename, boolean bUseAlternativeLocations) Construct a file reader for a file name.FileAccess(SessionInterface iSession, String directoryName, String fileName) -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists()Does the file exist?org.jdom2.DocumentGet document from file.org.jdom2.DocumentgetDocument(boolean optional) Get document from file.Get file content from file.Get the file name of this file.static StringgetFilenameWithExtension(String sFilename, String extension) static StringgetTempDirectory(SessionInterface session) voidsetDirectory(String iDir) Change the directory of the file without renaming the file.voidsetDocument(org.jdom2.Document iDocument) Set content of document to file.voidsetFilecontent(String iFilecontent) Set file content to file.toString()
-
Constructor Details
-
FileAccess
Construct a file reader for a file name.- Parameters:
iSession-iFilename- path and file namebUseAlternativeLocations- use alternative locations for file if not found on preferred location
-
FileAccess
public FileAccess(SessionInterface iSession, String directoryName, String fileName) throws RemoteException, M2MException - Throws:
RemoteExceptionM2MException
-
FileAccess
Construct a file reader for a file name.- Parameters:
iSession-file- construction File instance for determine file name- Throws:
RemoteExceptionM2MException
-
-
Method Details
-
setDirectory
Change the directory of the file without renaming the file.- Parameters:
iDir- new directory for the file
-
getFilename
Get the file name of this file.- Returns:
- The fully qualified path and file name.
-
exists
public boolean exists()Does the file exist?- Returns:
- true if the file exists
-
getFileContent
Get file content from file.- Returns:
- file content
- Throws:
SevereExceptionRemoteException
-
getDocument
Get document from file.- Returns:
- JDOM document if found, else an exception is thrown
- Throws:
M2MExceptionAbortExceptionSevereExceptionRemoteException
-
getDocument
Get document from file.- Parameters:
optional- if true and document is not found, a null is returned if false and document is not found, an exception is thrown- Returns:
- JDOM document if found
- Throws:
M2MExceptionAbortExceptionSevereExceptionRemoteException
-
setDocument
public void setDocument(org.jdom2.Document iDocument) throws SevereException, RemoteException, UncriticalException Set content of document to file.- Parameters:
iDocument- JDOM document- Throws:
SevereExceptionRemoteExceptionUncriticalException
-
setFilecontent
Set file content to file.- Parameters:
iFilecontent- content of file- Throws:
SevereExceptionRemoteException
-
toString
-
getTempDirectory
public static String getTempDirectory(SessionInterface session) throws RemoteException, M2MException - Throws:
RemoteExceptionM2MException
-
getFilenameWithExtension
-
getStringWriter
- Throws:
IOException
-