The Utility class to help file operating.
Method Summary | |
---|---|
static java.io.InputStream |
getInputStreamFromFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
Return an InputStream of the file on the specified path. |
static org.jdom.Element |
loadXMLFile(java.lang.String filePath)
Load the root element of an XML file. |
static org.jdom.Element |
loadXMLFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
Load the root element of an XML file. |
static java.lang.String |
openFileDialog(boolean inWorkspace)
Open a file select dialog. |
static java.lang.String |
readTextFile(java.lang.String filePath)
Read a text file. |
static java.lang.String |
readTextFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
Read a text file. |
static void |
writeTextFile(java.lang.String filePath,
boolean inWorkspace,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget,
java.lang.String text,
boolean append)
Write a text file. |
static void |
writeTextFile(java.lang.String filePath,
boolean inWorkspace,
java.lang.String text,
boolean append)
Write a text file. |
Method Detail |
---|
public static org.jdom.Element loadXMLFile(java.lang.String filePath) throws java.lang.Exception
filePath
- path of the file. It must be an absolute path which can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
. *
java.lang.Exception
- if the file does not exist or is not a correct XML file.public static org.jdom.Element loadXMLFile(java.lang.String filePath, org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget) throws java.lang.Exception
filePath
- path of the file. It can be an absolute path or a relative path to
the OPI that contains the specified widget. If it is an absolute path, it can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
.widget
- a widget in the OPI, which is used to provide relative path reference. It
can be null if the path is an absolute path.
java.lang.Exception
- if the file does not exist or is not a correct XML file.public static java.io.InputStream getInputStreamFromFile(java.lang.String filePath, org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget) throws java.lang.Exception
InputStream
of the file on the specified path.
The client is responsible for closing the stream when finished.
filePath
- path of the file. It can be an absolute path or a relative path to
the OPI that contains the specified widget. If it is an absolute path, it can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
.widget
- a widget in the OPI, which is used to provide relative path reference. It
can be null if the path is an absolute path.
java.lang.Exception
- if the file does not exist.public static java.lang.String readTextFile(java.lang.String filePath) throws java.lang.Exception
filePath
- path of the file. It must be an absolute path which can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
.
java.lang.Exception
- if the file does not exist or is not a correct text file.public static java.lang.String readTextFile(java.lang.String filePath, org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget) throws java.lang.Exception
filePath
- path of the file. It can be an absolute path or a relative path to
the OPI that contains the specified widget. If it is an absolute path, it can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
.widget
- a widget in the OPI, which is used to provide relative path reference. It
can be null if the path is an absolute path.
java.lang.Exception
- if the file does not exist or is not a correct text file.public static void writeTextFile(java.lang.String filePath, boolean inWorkspace, java.lang.String text, boolean append) throws java.lang.Exception
filePath
- path of the file. It must be an absolute path which can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
.inWorkspace
- true if the file path is a workspace file path. Otherwise, it will be
recognized as a local file system file.text
- the text to be written to the file.append
- true if the text should be appended to the end of the file.
java.lang.Exception
- if error happens.public static void writeTextFile(java.lang.String filePath, boolean inWorkspace, org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget, java.lang.String text, boolean append) throws java.lang.Exception
filePath
- path of the file. It can be an absolute path or a relative path to
the OPI that contains the specified widget. If it is an absolute path, it can be either/BOY Examples/Scripts/myfile.xml
C:\myfile.xml
http://mysite.com/myfile.xml
.inWorkspace
- true if the file path is a workspace file path. Otherwise, it will be
recognized as a local file system file.widget
- a widget in the OPI, which is used to provide relative path reference. It
can be null if the path is an absolute path.text
- the text to be written to the file.append
- true if the text should be appended to the end of the file.
java.lang.Exception
- if error happens.public static java.lang.String openFileDialog(boolean inWorkspace)
inWorkspace
- true if it is a workspace file dialog; Otherwise, it is a local
file system file dialog.