public class FileUtil
extends java.lang.Object
| Constructor and Description |
|---|
FileUtil() |
| Modifier and Type | Method and Description |
|---|---|
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 void |
openFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
Open a file in default editor.
|
static java.lang.String |
openFileDialog(boolean inWorkspace)
Open a file select dialog.
|
static void |
openWebPage(java.lang.String link)
Open a web page.
|
static void |
playWavFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
Play a .wav file.
|
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 java.lang.String |
saveFileDialog(boolean inWorkspace)
Open a file save dialog.
|
static java.lang.String |
workspacePathToSysPath(java.lang.String workspacePath)
Convert a workspace path to system path.
|
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.
|
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.xmlC:\myfile.xmlhttp://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.xmlC:\myfile.xmlhttp://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.xmlC:\myfile.xmlhttp://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.xmlC:\myfile.xmlhttp://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.xmlC:\myfile.xmlhttp://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.xmlC:\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.xmlC:\myfile.xmlhttp://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 void openFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
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
a workspace path such as /BOY Examples/Scripts/myfile.txtC:\myfile.txt.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.public static void openWebPage(java.lang.String link)
link - link to the web page. It can be a link started with http://, https:// or file://.public static void playWavFile(java.lang.String filePath,
org.csstudio.opibuilder.editparts.AbstractBaseEditPart widget)
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.xmlC:\myfile.xmlhttp://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.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.public static java.lang.String saveFileDialog(boolean inWorkspace)
inWorkspace - true if it is a workspace file dialog; Otherwise, it is a local
file system file dialog.public static java.lang.String workspacePathToSysPath(java.lang.String workspacePath)
throws java.lang.RuntimeException
workspacePath - path in workspace.java.lang.RuntimeException