public class PhantomFile extends Object implements NetPhantomConstants
New functions to create a buffered FileReader and FileWriter
using different encodings is now also available. See the methods
createFileReader
and createFileWriter
.
Modifier and Type | Field and Description |
---|---|
static String[] |
dayNames
The month names.
|
static String[] |
monthNames
The month names.
|
ACTION_CLOSEWINDOW, ACTION_CONTROL, ACTION_HOSTKEY, ACTION_MENU, ACTION_NONE, ACTION_NOTEBOOKPAGE, ACTION_POPUPMENU, CC_BACKGROUND, CC_BOTH, CC_FOREGROUND, CC_NONE, CLIPBOARD_GET, CLIPBOARD_SET, DATEF_DMY, DATEF_MDY, DATEF_SYSTEM, DATEF_YMD, DDE_ADVISE, DDE_EXECUTE, DDE_INITIATE, DDE_POKE, DDE_REQUEST, DDE_TERMINATE, DDE_UNADVISE, DDE_UPDATE, DDEVAR_DISABLE, DDEVAR_ENABLE, DDEVAR_REQUEST, DDEVAR_SET, DDEVAR_VALIDATE, EFT_AMOUNT, EFT_DATE, EFT_DATEAMOUNT, EFT_NORMAL, EFT_PASSWORD, EVENT_CHAR, EVENT_CHECK, EVENT_CLICK, EVENT_COMMAND, EVENT_DBLCLICK, EVENT_DDECONNECTION, EVENT_DDEDATA, EVENT_DDEERROR, EVENT_DDEEXECUTE, EVENT_DDEINVALIDATE, EVENT_DDEPOKE, EVENT_DDEREQUEST, EVENT_DEFOCUS, EVENT_FOCUS, EVENT_PAGEDOWN, EVENT_PAGEUP, EVENT_SELECT, EVENT_UNKNOWN, EVENT_USERCHANGE, EXTENDEDINFO_IDS_TO_CLIENT, FOCUSTYPE_CLIENTTARGET, FOCUSTYPE_CONTROL, FOCUSTYPE_NONE, ICON_CRITICAL, ICON_INFORMATION, ICON_NOICON, ICON_QUERY, ICON_WARNING, J_AUTO, J_BOTTOM, J_BOTTOMLEFT, J_BOTTOMRIGHT, J_CENTER, J_LEFT, J_RIGHT, J_TOP, J_TOPLEFT, J_TOPRIGHT, MAX_PANELS_PER_SESSION, MAX_SESSIONS, MB_ABORTRETRYIGNORE, MB_CANCEL, MB_ENTER, MB_ENTERCANCEL, MB_OK, MB_OKCANCEL, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL, MBID_CANCEL, MBID_DEFAULT, MBID_ENTER, MBID_IGNORE, MBID_NO, MBID_OK, MBID_RETRY, MBID_YES, MS_MOVE, MS_NONE, MS_SIZE, NETPHANTOM_COPYRIGHT, NETPHANTOM_COPYRIGHT2, NETPHANTOM_VERSION, OBJEVENT_CHECK, OBJEVENT_CLICK, OBJEVENT_DBLCLICK, OBJEVENT_DEFOCUS, OBJEVENT_FOCUS, OBJEVENT_SELECT, OBJEVENT_USERCHANGE, PANELCREATE_APPPANEL, PANELCREATE_DANGLINGPANEL, PANELCREATE_DLGFRAME, PANELCREATE_EXTENDEDINFO, PANELCREATE_ICON, PANELCREATE_INDIVIDUALSIZE, PANELCREATE_POPUP, REPLYTYPE_CLIENTEXECUTE, REPLYTYPE_CLIPBOARD, REPLYTYPE_DDE, REPLYTYPE_FFONTLIST, REPLYTYPE_MESSAGEBOX, REPLYTYPE_REPORT, REPLYTYPE_SAVEPROPS, REPLYTYPE_TERMMARK, RPRT_CANCELPRINTJOB, RPRT_CLOSEPRINTJOB, RPRT_CONTPRINTJOB, RPRT_OPENPRINTJOB, RPRT_PRINTJOBCANCLD, RPRT_PRINTJOBCLOSED, RPRT_PRINTJOBCONT, RPRT_PRINTJOBOPENED, RPRT_PRINTJOBSTARTED, RPRT_STARTPRINTJOB, SELMODE_NORMAL, SELMODE_NOTALLOWED, SELMODE_REQUIRED, SELTYPE_MULTIPLE, SELTYPE_SINGLE, SEPARATOR, SEPARATORCHAR, TRANS_APPLICATIONCHANGE, TRANS_CALLOBJECT, TRANS_CANCELEXIT, TRANS_CLEARLOCK, TRANS_CLIENTEXECUTE, TRANS_CLIENTJARS, TRANS_CLIENTTEXTTABLE, TRANS_CLIENTUPDATED, TRANS_CLIENTUPDATEDNOLOCK, TRANS_CLIPBOARD, TRANS_CLIPBOARDCOMPONENT, TRANS_CLOSETERMINALWINDOW, TRANS_CONNECTIONREFUSED, TRANS_COUNTRYINFO, TRANS_CREATEPANEL, TRANS_CREATESESSION, TRANS_DDE, TRANS_DDEEVENT, TRANS_DDEEVENTREPLY, TRANS_DDEVAREVENT, TRANS_DISPLAYHELP, TRANS_DISPLAYTERMINAL, TRANS_DISPLAYTOOLTIPS, TRANS_ENDCONVERSATION, TRANS_EXIT, TRANS_FONTSUBSTITUTION, TRANS_HOSTCOLORTABLE, TRANS_HOSTPRINT, TRANS_HWND, TRANS_INACTIVESESSION, TRANS_INITIATE, TRANS_KEEPALIVE, TRANS_LOCALE, TRANS_LOGEVENT, TRANS_MESSAGEBOX, TRANS_MESSAGEBOXWITHREPLY, TRANS_MODALREPLY, TRANS_MULTTERM, TRANS_PING, TRANS_PRINTCOMPONENT, TRANS_PRINTPANEL, TRANS_PRINTREPORT, TRANS_PRTWINKEY, TRANS_RECONNECT, TRANS_REDIRECTION, TRANS_REMOVEPANELATLEVEL, TRANS_REMOVETERMINAL, TRANS_RENEGOTIATESSL, TRANS_REQUESTHELP, TRANS_RESOURCEURL, TRANS_SELECTSESSION, TRANS_SESSIONACTIVE, TRANS_SESSIONSELECTED, TRANS_SETCOLORS, TRANS_SETFOCUS, TRANS_SETLOCK, TRANS_SETPANELNESTLEVEL, TRANS_SETUPPARAMS, TRANS_SHOWDOCUMENT, TRANS_SOCKET, TRANS_SOUNDALARM, TRANS_STARTUPINFO, TRANS_STOPSESSION, TRANS_TERMINALDATA, TRANS_TERMINALUPDATE, TRANS_TERMINALWINDOW, TRANS_TERMWINTEXT, TRANS_UPDATEAPPLICATION, TRANS_UPDATEPANEL, TRANS_USEREXITPRTKEY, TRANSACTION_VERSION, TS_CLOSE, TS_DATA, TS_ERROR, TS_OPEN, VSIGN_MINUS, VSIGN_NONE, VSIGN_PLUSMINUS, YEARF_6DIG, YEARF_8DIG, YEARF_EXP8
Constructor and Description |
---|
PhantomFile(byte[] data)
Creates a new instance of a file in memory.
|
PhantomFile(byte[] data,
PhantomFile openFile)
Creates a new instance of a file in memory.
|
PhantomFile(byte[] data,
String fileName)
Creates a new instance of a file in memory.
|
PhantomFile(File file)
Creates a new instance of a file from an input stream, typically from ZIP/JAR files.
|
PhantomFile(InputStream in)
Creates a new instance of a file from an input stream, typically from ZIP/JAR files.
|
PhantomFile(InputStream in,
String fileName)
Creates a new instance of a file from an input stream, typically from ZIP/JAR files.
|
PhantomFile(PhantomFile file,
int position)
Opens a new instance of a file at a specified
file position.
|
PhantomFile(String fileName)
Opens the specified file for read.
|
PhantomFile(String fileName,
boolean doSearchPath)
Opens the specified file for read.
|
PhantomFile(String fileName,
PhantomFile openFile)
Opens the specified file for read.
|
PhantomFile(String fileName,
String previousFile)
Opens the specified file for read.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close stream and file.
|
static boolean |
deleteFileAndChildren(File dir)
Deletes a file or directory along with all its children (in case of a directory).
|
static String |
findFileInDirectory(File dir,
String fileName,
boolean matchCase)
Finds a file in a directory or in one of it's sub-directories.
|
static String |
findFileInDirectory(String dir,
String fileName,
boolean matchCase)
Finds a file in a directory or in one of it's sub-directories.
|
static String |
findFileInPath(String fileName)
Locates the specified file.
|
static String |
findFileInPath(String fileName,
boolean doSearchPath)
Locates the specified file.
|
static int |
findFilesInDirectory(File dir,
ArrayList<String> fileNames,
boolean matchCase,
VirtualControl dirDisplay)
Finds a file in a directory or in one of it's sub-directories.
|
static int |
findFilesInDirectory(String dir,
ArrayList<String> fileNames,
boolean matchCase,
VirtualControl dirDisplay)
Finds a file in a directory or in one of it's sub-directories.
|
static String |
getBaseName(String fn)
Gets the base file name without path and file extension.
|
static File |
getCanonicalFile(File f)
Gets the canonical file if possible, if it fails with IOException the
absolute path is returned.
|
static File |
getCanonicalFile(String filePath)
Gets the canonical file if possible, if it fails with IOException the
absolute path is returned.
|
static String |
getCanonicalPath(File f)
Gets the canonical file path if possible, if it fails with IOException the
absolute path is returned.
|
static String |
getCanonicalPath(String filePath)
Gets the canonical file path if possible, if it fails with IOException the
absolute path is returned.
|
static String |
getFileExtension(File file)
Gets the extension of a file.
|
static String |
getFileExtension(String fileName)
Gets the extension of a file.
|
String |
getFileName()
Gets the file name.
|
String |
getFileNameFromAnother(String base)
Returns a file name and path that is taken from the current
PhantomFile instance with path, but with the base name of the
file name in PhantomFile.
|
static String |
getFileNameFromAnother(String base,
String another)
Returns a file name and path that is taken from a file
with path, but with the base name of another file.
|
String |
getFileTimestamp()
Get file time stamp as DayName Month day HH:MM:SS year.
|
static String |
getFileTimestamp(long lastModified)
Get file time stamp as DayName Month day HH:MM:SS year.
|
static String |
getFileTimestamp(String fileName)
Get file time stamp as DayName Month day HH:MM:SS year.
|
byte |
getMemoryDataByte()
Gets the current byte from the memory data (same as readByte but without
advancing the position).
|
static String |
getRelativeFileName(String fileName,
String reference)
Gets the relative file name from another file (if possible).
|
static String |
getRelativeFileName(String fileName,
String reference,
boolean canonicalIfAbove)
Gets the relative file name from another file (if possible).
|
static String |
getRelativeFileName(String fileName,
String reference,
boolean mustBeChildOrSibling,
boolean stripRelativePath,
boolean mustExist,
boolean mustBeFile)
Gets a file name relative to a reference file name.
|
static String |
getRelativePath(File home,
File f)
Get relative path of File 'f' with respect to 'home' directory.
|
static String |
getRelativePath(File home,
File f,
boolean canonicalIfAbove)
Get relative path of File 'f' with respect to 'home' directory.
|
int |
getRemainingSize()
Gets the remaining size in the memory file.
|
static boolean |
hasFileExtension(File file,
boolean caseSensitive,
String... extensions)
Checks the extension of a file for a valid one with the ones specified in the list
of extensions.
|
static boolean |
hasFileExtension(String fileName,
boolean caseSensitive,
String... extensions)
Checks the extension of a file for a valid one with the ones specified in the list
of extensions.
|
static boolean |
isJarOrZipFile(File file)
Checks if a file is of Jar or Zip file type (i.e.
|
static boolean |
isJarOrZipFile(String fileName)
Checks if a file is of Jar or Zip file type (i.e.
|
static boolean |
isSameFile(File f1,
File f2)
Checks if two file names refer to the same file, i.e.
|
static boolean |
isSameFile(String fn1,
String fn2)
Checks if two file names refer to the same file, i.e.
|
long |
lastModified()
Returns the time that the file represented by this file object was last modified.
|
static boolean |
listDirectory(File dir,
ArrayList<File> array)
Gets a directory listing including all children and sub-directories.
|
static boolean |
listDirectory(String dir,
ArrayList<File> array)
Gets a directory listing including all children and sub-directories.
|
static byte[] |
loadFile(File file)
Loads a file into memory.
|
static byte[] |
loadFile(InputStream in)
Loads a file into memory.
|
static byte[] |
loadFile(JarFile jar,
JarEntry je)
Loads a file into memory.
|
static byte[] |
loadFile(PhantomFile file)
Loads a file into memory.
|
static byte[] |
loadFile(String fileName)
Loads a file into memory.
|
byte[] |
read(int size)
Reads a number of bytes from the file.
|
String |
readAnsiLine()
Reads a line in the file up to the next new line (CR/LF or just LF) or the end
of the file.
|
Vector<String> |
readBOMStringVector(boolean skipEmptyLines,
boolean trimLeading,
boolean trimTrailing,
String encoding)
Reads the file until end as a string vector.
|
boolean |
readBoolean()
Reads a boolean byte value from file.
|
int |
readByte()
Reads an unsigned byte value from the file.
|
byte[] |
readByteLine()
Reads a line in the file up to the next new line (CR/LF or just LF) or the end
of the file.
|
double |
readIntelDouble()
Reads a double value from the file.
|
int |
readIntelLong()
Reads a signed long value from the file in Intel style.
|
int |
readIntelShort()
Reads an signed short value from the file in Intel style.
|
int |
readIntelUShort()
Reads an unsigned short value from the file in Intel style.
|
String |
readISOLine()
Reads a line in the file up to the next new line (CR/LF or just LF) or the end
of the file.
|
String |
readOEMBytes(int size)
Reads a number of OEM bytes and returns it as a string.
|
String |
readOEMLine()
Reads a line in the file up to the next new line (CR/LF or just LF) or the end
of the file.
|
String |
readOEMString()
Reads a number of OEM bytes and returns it as a string.
|
String |
readOEMString(int size)
Reads a number of OEM bytes and returns it as a string.
|
Vector<String> |
readOEMStringVector(boolean skipEmptyLines)
Reads the file until end as a string vector.
|
Vector<String> |
readOEMStringVector(boolean skipEmptyLines,
boolean trimLines)
Reads the file until end as a string vector.
|
Vector<String> |
readOEMStringVector(boolean skipEmptyLines,
boolean trimLeading,
boolean trimTrailing)
Reads the file until end as a string vector.
|
String |
readString()
Reads a number of bytes and returns it as a string.
|
String |
readString(int size)
Reads a number of bytes and returns it as a string.
|
String |
readUnicodeChars(int size)
Reads a number of Unicode characters (16-bit words) and returns it as a string.
|
String |
readUnicodeString(int size)
Reads a number of Unicode characters (16-bit words) and returns it as a string.
|
void |
skipBytes(int n)
Skips a number of bytes.
|
public static final String[] monthNames
public static final String[] dayNames
public PhantomFile(String fileName) throws IOException
IOException
- if an I/O error occurs.public PhantomFile(String fileName, boolean doSearchPath) throws IOException
IOException
- if an I/O error occurs.public PhantomFile(String fileName, PhantomFile openFile) throws IOException
IOException
- if an I/O error occurs.public PhantomFile(String fileName, String previousFile) throws IOException
IOException
- if an I/O error occurs.public PhantomFile(PhantomFile file, int position) throws IOException
IOException
- if an I/O error occurs.public PhantomFile(byte[] data)
public PhantomFile(byte[] data, String fileName)
public PhantomFile(byte[] data, PhantomFile openFile)
public PhantomFile(InputStream in)
public PhantomFile(InputStream in, String fileName)
public PhantomFile(File file) throws FileNotFoundException
FileNotFoundException
- if file is not found.public static byte[] loadFile(InputStream in) throws IOException
in
- the input stream.FileNotFoundException
- if the file cannot be found.IOException
- if the file cannot be loaded.public static byte[] loadFile(PhantomFile file) throws IOException
FileNotFoundException
- if the file cannot be found.IOException
- if the file cannot be loaded.public static byte[] loadFile(String fileName) throws IOException
FileNotFoundException
- if the file cannot be found.IOException
- if the file cannot be loaded.public static byte[] loadFile(File file) throws IOException
FileNotFoundException
- if the file cannot be found.IOException
- if the file cannot be loaded.public static byte[] loadFile(JarFile jar, JarEntry je) throws IOException
FileNotFoundException
- if the file cannot be found.IOException
- if the file cannot be loaded.public void close()
public static String getFileNameFromAnother(String base, String another)
public String getFileNameFromAnother(String base)
public byte[] read(int size) throws IOException
IOException
- if an I/O error occurs.public String readString() throws IOException
IOException
- if an I/O error occurs.readOEMString()
public String readString(int size) throws IOException
IOException
- if an I/O error occurs.readOEMString()
public String readOEMString() throws IOException
IOException
- if an I/O error occurs.readString()
,
readOEMBytes(int)
public String readOEMString(int size) throws IOException
IOException
- if an I/O error occurs.readString()
,
readOEMBytes(int)
public String readUnicodeString(int size) throws IOException
IOException
- if an I/O error occurs.read(int)
,
readOEMString()
public String readOEMBytes(int size) throws IOException
IOException
- if an I/O error occurs.read(int)
,
readOEMString()
public String readUnicodeChars(int size) throws IOException
IOException
- if an I/O error occurs.read(int)
,
readOEMString()
public int readByte() throws IOException
IOException
- if an I/O error occurs.public boolean readBoolean() throws IOException
IOException
- if an I/O error occurs.public int readIntelUShort() throws IOException
IOException
- if an I/O error occurs.public int readIntelShort() throws IOException
IOException
- if an I/O error occurs.public int readIntelLong() throws IOException
IOException
- if an I/O error occurs.public double readIntelDouble() throws IOException
IOException
- if an I/O error occurs.public void skipBytes(int n) throws IOException
IOException
- if an I/O error occurs.public int getRemainingSize()
public String getFileName()
public Vector<String> readOEMStringVector(boolean skipEmptyLines) throws IOException
IOException
- if an I/O error occurs.public Vector<String> readOEMStringVector(boolean skipEmptyLines, boolean trimLines) throws IOException
IOException
- if an I/O error occurs.public Vector<String> readOEMStringVector(boolean skipEmptyLines, boolean trimLeading, boolean trimTrailing) throws IOException
IOException
- if an I/O error occurs.public Vector<String> readBOMStringVector(boolean skipEmptyLines, boolean trimLeading, boolean trimTrailing, String encoding) throws IOException
IOException
- if an I/O error occurs.public byte[] readByteLine() throws IOException
IOException
- if an I/O error occurs.PhantomOutputFile.writeLine(byte[])
public String readOEMLine() throws IOException
IOException
- if an I/O error occurs.public String readAnsiLine() throws IOException
IOException
- if an I/O error occurs.public String readISOLine() throws IOException
Typically, this function is used to read data that have been written with PhantomOutputFile.writeISOLine.
IOException
- if an I/O error occurs.PhantomOutputFile.writeISOLine(java.lang.String)
public byte getMemoryDataByte()
public static String findFileInPath(String fileName)
public static String findFileInPath(String fileName, boolean doSearchPath)
public static String findFileInDirectory(String dir, String fileName, boolean matchCase)
public static String findFileInDirectory(File dir, String fileName, boolean matchCase)
public static int findFilesInDirectory(String dir, ArrayList<String> fileNames, boolean matchCase, VirtualControl dirDisplay)
public static int findFilesInDirectory(File dir, ArrayList<String> fileNames, boolean matchCase, VirtualControl dirDisplay)
public long lastModified()
public static String getFileTimestamp(String fileName)
public String getFileTimestamp()
public static String getFileTimestamp(long lastModified)
public static String getBaseName(String fn)
public static boolean isSameFile(String fn1, String fn2)
public static boolean isSameFile(File f1, File f2)
public static String getCanonicalPath(File f)
public static File getCanonicalFile(File f)
public static String getCanonicalPath(String filePath)
public static File getCanonicalFile(String filePath)
public static String getRelativeFileName(String fileName, String reference, boolean mustBeChildOrSibling, boolean stripRelativePath, boolean mustExist, boolean mustBeFile) throws IOException, FileNotFoundException
IOException
FileNotFoundException
public static String getRelativePath(File home, File f, boolean canonicalIfAbove) throws IOException
example : home = /a/b/c f = /a/d/e/x.txt s = getRelativePath(home,f) = ../../d/e/x.txt
home
- base path, should be a directory, not a file, or it doesn't make sense.f
- file to generate path for.IOException
- for file failures.public static String getRelativePath(File home, File f) throws IOException
example : home = /a/b/c f = /a/d/e/x.txt s = getRelativePath(home,f) = ../../d/e/x.txt
home
- base path, should be a directory, not a file, or it doesn't make sense.f
- file to generate path for.IOException
- for file failures.public static String getRelativeFileName(String fileName, String reference)
public static String getRelativeFileName(String fileName, String reference, boolean canonicalIfAbove)
public static boolean listDirectory(String dir, ArrayList<File> array)
public static boolean listDirectory(File dir, ArrayList<File> array)
public static boolean deleteFileAndChildren(File dir)
public static String getFileExtension(File file)
file
- the file.public static String getFileExtension(String fileName)
fileName
- the file name.public static boolean hasFileExtension(File file, boolean caseSensitive, String... extensions)
file
- the file.caseSensitive
- if case sensitivity is used or not.extensions
- a variable length of file extensions without the ".",
e.g. "html","htm" for HTML files.public static boolean hasFileExtension(String fileName, boolean caseSensitive, String... extensions)
fileName
- the file name.caseSensitive
- if case sensitivity is used or not.extensions
- a variable length of file extensions without the ".",
e.g. "html","htm" for HTML files.public static boolean isJarOrZipFile(String fileName)
public static boolean isJarOrZipFile(File file)
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.