Package hec.io
Interface HecFile
- All Known Implementing Classes:
SimpleFile
,SimpleHecFileImpl
public interface HecFile
HecFile is a file for use in both a RMI Networked and Local environment.
HecFile's intent is to be the client side file object.
Construct a HecFile using a FilePath Object or with a RmiFileImpl RemoteWrapper.
Use getBufferedReader for UNICODE Reading of a HecFile.
Use getBufferedWriter for UNICODE Writing of a HecFile.
NOTE - the writing must be followed by a save() to send the byte[] to the RmiFileImpl.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
appendByteArray
(byte[] byteArray) Appends byteArray to the end of this file.boolean
canRead()
Tests whether the application can read the file denoted by this HecFile.boolean
canWrite()
Tests whether the application can modify the file denoted by this HecFile.void
close()
Closes any open writers and flushes their data to disk.boolean
exists()
Tests whether the file denoted by this HecFile exists.Get a BufferedWriter to append to the end of this file.Get a DataOutputStream for appending to the end of this file.Get a BufferedReader for this file.Get a BufferedWriter to write to this file.byte[]
Get the byte[] representing this HecFile's data.byte[]
getByteArray
(long off, int len) Get the byte[] representing this HecFile's data starting at offset for the length amount.Get a ByteArrayInputStream for this file.Get a ByteArrayOutputStream for this file.long
Get the check sum for this file.Get a DataInputStream for this file.Get a DataOutputStream for writing to this file.Get an EndianInputStream for this file.Get an EndianOutputStream for this file.default String
getName()
Sets the name of the file.Get an ObjectInputStream for this file.Get an ObjectOutputStream for this file.getPath()
Converts this HecFile into a pathname String.boolean
return whether thisHecFile
is using Compression to read/write data to theRmiFile
boolean
Tests whether the file denoted by this HecFile is a directory.boolean
isFile()
Tests whether the file denoted by this HecFile is a normal file.boolean
Get whether this HecFile represents a networked or local file.long
Returns the time that the file denoted by this HecFile was last modified.long
length()
Returns the length of the file denoted by this HecFile.boolean
Lock this file with fLock.boolean
mkdirs()
Creates the directory named by this HecFile, including any necessary but nonexistent parent directories.void
Send message to all callback objects registered with this file.boolean
save()
Save the contents of any writers that are currently in use.boolean
setByteArray
(byte[] byteArray) Set this HecFile's data to byteArray starting at the beginning of the filevoid
setUseCompression
(boolean compress) set whether thisHecFile
should use compression to read/write data to/from theRmiFile
boolean
unlockFile
(FileLock fLock) Unlock this file with fLock.void
writeBytes
(long bytePos, byte[] bytes) void
writeFloat
(long bytePos, float f) Write a float f to position bytePos in this HecFile.
-
Method Details
-
isDirectory
boolean isDirectory()Tests whether the file denoted by this HecFile is a directory. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the file denoted by this HecFile exists and is a directory; false otherwise.
-
getName
String getName()Sets the name of the file.
Locally this will run java.io.file.setName().
/** Returns the name of the file or directory denoted by this HecFile. This is just the last name int he pathname's name sequence. If the pathname's name sequence is empty, then the empty String is returned. Note: This method is implemented by java.io.File.- Returns:
- The name of the file or directory denoted by this HecFile, or the empty String if this pathname's name sequence is empty.
-
getPath
String getPath()Converts this HecFile into a pathname String. The resulting String uses the default name-separator character to separate the names in the name sequence. Note: This method is implemented by java.io.File.- Returns:
- The String form of this HecFile.
-
canRead
boolean canRead()Tests whether the application can read the file denoted by this HecFile. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the file specified by this HecFile exists and can be read by the application; false otherwise.
-
isFile
boolean isFile()Tests whether the file denoted by this HecFile is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the file denoted by the HecFile exists and is a normal file; false otherwise.
-
exists
boolean exists()Tests whether the file denoted by this HecFile exists. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the file denoted by this HecFile exists; false otherwise.
-
canWrite
boolean canWrite()Tests whether the application can modify the file denoted by this HecFile. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the file system actually contains a file denoted by this HecFile and the application is allowed to write to the file; false otherwise.
-
mkdirs
boolean mkdirs()Creates the directory named by this HecFile, including any necessary but nonexistent parent directories. Note that if this operation fails, it may have succeeded in creating some of the necessary parent directories. Note: This method is implemented by java.io.File.- Returns:
- True if and only if the directory was created, along with the necessary parent directories; false otherwise.
-
length
long length()Returns the length of the file denoted by this HecFile. The return value is unspecified if this pathname denotes a directory. Note: This method is implemented by java.io.File.- Returns:
- The length, in bytes, of the file denoted by the HecFile, or 0L if the file does not exist.
-
lastModified
long lastModified()Returns the time that the file denoted by this HecFile was last modified. Note: This method is implemented by java.io.File.- Returns:
- A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs.
-
getByteArray
byte[] getByteArray()Get the byte[] representing this HecFile's data. This may or may not be the complete contents of the file.- Returns:
- This HecFile's data.
-
getByteArray
byte[] getByteArray(long off, int len) Get the byte[] representing this HecFile's data starting at offset for the length amount. The may or may not be the complete contents of the file.- Parameters:
off
- the offset into the file's datalen
- the number of bytes to return. The actual number returned may be less if the file isn't offset+length long.- Returns:
- This HecFile's data starting at offset for length amount.
-
setByteArray
boolean setByteArray(byte[] byteArray) Set this HecFile's data to byteArray starting at the beginning of the file- Parameters:
byteArray
- the file's new data- Returns:
- True if the file's data was set to byteArray.
-
appendByteArray
boolean appendByteArray(byte[] byteArray) Appends byteArray to the end of this file.- Parameters:
byteArray
- the bytes to append to the end of this file.- Returns:
- True if the byteArray was written successfully to the end of this file.
-
getBufferedWriter
BufferedWriter getBufferedWriter()Get a BufferedWriter to write to this file.- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getAppendedBufferedWriter
BufferedWriter getAppendedBufferedWriter()Get a BufferedWriter to append to the end of this file.- Returns:
- A BufferedWriter for this file, or null if a writer is currently in use.
-
getDataOutputStream
DataOutputStream getDataOutputStream()Get a DataOutputStream for writing to this file.- Returns:
- A DataOutputStream for this file or null if a writer is currently in use.
-
getAppendedDataOutputStream
DataOutputStream getAppendedDataOutputStream()Get a DataOutputStream for appending to the end of this file.- Returns:
- A DataOutputStream for this file or null if a writer is currenly in use.
-
getDataInputStream
DataInputStream getDataInputStream()Get a DataInputStream for this file.- Returns:
- A DataInputStream for this file.
-
getObjectOutputStream
Get an ObjectOutputStream for this file.- Returns:
- The ObjectOutputStream for this file or null if a writer is currently in use.
- Throws:
IOException
-
getObjectInputStream
ObjectInputStream getObjectInputStream()Get an ObjectInputStream for this file.- Returns:
- An ObjectInputStream for this file.
-
getByteArrayOutputStream
ByteArrayOutputStream getByteArrayOutputStream()Get a ByteArrayOutputStream for this file.- Returns:
- A ByteArrayOutputStream for this file, or null if a writer is currently in use.
-
getByteArrayInputStream
ByteArrayInputStream getByteArrayInputStream()Get a ByteArrayInputStream for this file.- Returns:
- A ByteArrayInputStream for reading this file.
-
getEndianInputStream
EndianInputStream getEndianInputStream()Get an EndianInputStream for this file.- Returns:
- An EndianInputStram for this file.
-
getEndianOutputStream
EndianOutputStream getEndianOutputStream()Get an EndianOutputStream for this file.- Returns:
- An EndianOutputStream for this file or null if a writer is currently in use.
-
save
boolean save()Save the contents of any writers that are currently in use.- Returns:
- True if the save was successful.
-
getBufferedReader
BufferedReader getBufferedReader()Get a BufferedReader for this file.- Returns:
- A BufferedReader for this file.
-
notify
Send message to all callback objects registered with this file.- Parameters:
message
- The notification message.
-
close
Closes any open writers and flushes their data to disk.- Throws:
IOException
-
getCheckSum
long getCheckSum()Get the check sum for this file.- Returns:
- The CRC32 check sum for this file.
- See Also:
-
isNetworked
boolean isNetworked()Get whether this HecFile represents a networked or local file.- Returns:
- Ture is this HecFile is networked.
-
lockFile
Lock this file with fLock.- Parameters:
fLock
- The type of FileLock to use to lock this HecFile.- Returns:
- True if the file was locked successfully.
-
unlockFile
Unlock this file with fLock.- Parameters:
fLock
- The type of FileLock to use to unlock this HecFile.- Returns:
- True if the file unlocked successfully.
-
setUseCompression
void setUseCompression(boolean compress) set whether thisHecFile
should use compression to read/write data to/from theRmiFile
- Parameters:
compress
- whether to use compression or not
-
getUsingCompression
boolean getUsingCompression()return whether thisHecFile
is using Compression to read/write data to theRmiFile
- Returns:
- whether compression is being used
-
writeFloat
void writeFloat(long bytePos, float f) Write a float f to position bytePos in this HecFile.- Parameters:
bytePos
- The position in the file to write f.f
- The float to write.
-
getLineSeparator
- Returns:
- The line separator to use for this HecFile. This may not be the same as System.lineSeparator for remote files.
-
writeBytes
void writeBytes(long bytePos, byte[] bytes)
-