Package hec.io
Class SimpleFile
java.lang.Object
java.io.File
hec.io.SimpleFile
- All Implemented Interfaces:
HecFile
,Serializable
,Comparable<File>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static boolean
Default value for write to a tmp file.protected boolean
whether to write to a tmp file instead of the real file during writesprotected static final String
extension used for backup filesprotected static final String
extension used for temp filesFields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleFile
(File parent, String child) SimpleFile
(String pathname) SimpleFile
(String parent, String child) -
Method Summary
Modifier and TypeMethodDescriptionboolean
appendByteArray
(byte[] byteArray) Appends byteArray to the end of this file.void
close()
Closes any open writers and flushes their data to disk.protected void
copies src to dest - does no checking of the files.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
(boolean compress) Return a byte[] containing the data from the File.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.Get an ObjectInputStream for this file.Get an ObjectOutputStream for this file.boolean
return whether thisHecFile
is using Compression to read/write data to theRmiFile
boolean
Get whether this HecFile represents a networked or local file.boolean
Lock this file with fLock.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
static void
setWriteToTmpFile
(boolean writeToTmp) 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.Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface hec.io.HecFile
canRead, canWrite, exists, getLineSeparator, getName, getPath, isDirectory, isFile, lastModified, length, mkdirs
-
Field Details
-
TMP_EXTENSION
extension used for temp files- See Also:
-
BAK_EXTENSION
extension used for backup files- See Also:
-
_staticWriteToTmpDefault
protected static boolean _staticWriteToTmpDefaultDefault value for write to a tmp file. -
_writeToTmp
protected boolean _writeToTmpwhether to write to a tmp file instead of the real file during writes
-
-
Constructor Details
-
SimpleFile
- Parameters:
parent
-child
-
-
SimpleFile
-
SimpleFile
-
-
Method Details
-
setWriteToTmpFile
public static void setWriteToTmpFile(boolean writeToTmp) -
appendByteArray
public boolean appendByteArray(byte[] byteArray) Description copied from interface:HecFile
Appends byteArray to the end of this file.- Specified by:
appendByteArray
in interfaceHecFile
- Parameters:
byteArray
-- Returns:
- See Also:
-
copyFile
copies src to dest - does no checking of the files.- Throws:
IOException
-
close
Description copied from interface:HecFile
Closes any open writers and flushes their data to disk.- Specified by:
close
in interfaceHecFile
- Throws:
IOException
- See Also:
-
getAppendedBufferedWriter
Description copied from interface:HecFile
Get a BufferedWriter to append to the end of this file.- Specified by:
getAppendedBufferedWriter
in interfaceHecFile
- Returns:
- See Also:
-
getAppendedDataOutputStream
Description copied from interface:HecFile
Get a DataOutputStream for appending to the end of this file.- Specified by:
getAppendedDataOutputStream
in interfaceHecFile
- Returns:
- See Also:
-
getBufferedReader
Description copied from interface:HecFile
Get a BufferedReader for this file.- Specified by:
getBufferedReader
in interfaceHecFile
- Returns:
- See Also:
-
getBufferedWriter
Description copied from interface:HecFile
Get a BufferedWriter to write to this file.- Specified by:
getBufferedWriter
in interfaceHecFile
- Returns:
- See Also:
-
getByteArray
public byte[] getByteArray()Description copied from interface:HecFile
Get the byte[] representing this HecFile's data. This may or may not be the complete contents of the file.- Specified by:
getByteArray
in interfaceHecFile
- Returns:
- See Also:
-
getByteArray
public byte[] getByteArray(boolean compress) Return a byte[] containing the data from the File.- Parameters:
compress
- flag indicating whether to compress the byte[] being returned
-
getByteArray
public byte[] getByteArray(long off, int len) Description copied from interface:HecFile
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.- Specified by:
getByteArray
in interfaceHecFile
- Parameters:
off
-len
-- Returns:
- See Also:
-
getByteArrayInputStream
Description copied from interface:HecFile
Get a ByteArrayInputStream for this file.- Specified by:
getByteArrayInputStream
in interfaceHecFile
- Returns:
- See Also:
-
getByteArrayOutputStream
Description copied from interface:HecFile
Get a ByteArrayOutputStream for this file.- Specified by:
getByteArrayOutputStream
in interfaceHecFile
- Returns:
- See Also:
-
getCheckSum
public long getCheckSum()Description copied from interface:HecFile
Get the check sum for this file.- Specified by:
getCheckSum
in interfaceHecFile
- Returns:
- See Also:
-
getDataInputStream
Description copied from interface:HecFile
Get a DataInputStream for this file.- Specified by:
getDataInputStream
in interfaceHecFile
- Returns:
- See Also:
-
getDataOutputStream
Description copied from interface:HecFile
Get a DataOutputStream for writing to this file.- Specified by:
getDataOutputStream
in interfaceHecFile
- Returns:
- See Also:
-
getEndianInputStream
Description copied from interface:HecFile
Get an EndianInputStream for this file.- Specified by:
getEndianInputStream
in interfaceHecFile
- Returns:
- See Also:
-
getEndianOutputStream
Description copied from interface:HecFile
Get an EndianOutputStream for this file.- Specified by:
getEndianOutputStream
in interfaceHecFile
- Returns:
- See Also:
-
getObjectInputStream
Description copied from interface:HecFile
Get an ObjectInputStream for this file.- Specified by:
getObjectInputStream
in interfaceHecFile
- Returns:
- See Also:
-
getObjectOutputStream
Description copied from interface:HecFile
Get an ObjectOutputStream for this file.- Specified by:
getObjectOutputStream
in interfaceHecFile
- Returns:
- Throws:
IOException
- See Also:
-
getUsingCompression
public boolean getUsingCompression()Description copied from interface:HecFile
return whether thisHecFile
is using Compression to read/write data to theRmiFile
- Specified by:
getUsingCompression
in interfaceHecFile
- Returns:
- See Also:
-
isNetworked
public boolean isNetworked()Description copied from interface:HecFile
Get whether this HecFile represents a networked or local file.- Specified by:
isNetworked
in interfaceHecFile
- Returns:
- See Also:
-
lockFile
Description copied from interface:HecFile
Lock this file with fLock. -
notify
Description copied from interface:HecFile
Send message to all callback objects registered with this file. -
save
public boolean save()Description copied from interface:HecFile
Save the contents of any writers that are currently in use. -
setByteArray
public boolean setByteArray(byte[] byteArray) Description copied from interface:HecFile
Set this HecFile's data to byteArray starting at the beginning of the file- Specified by:
setByteArray
in interfaceHecFile
- Parameters:
byteArray
-- Returns:
- See Also:
-
setUseCompression
public void setUseCompression(boolean compress) Description copied from interface:HecFile
set whether thisHecFile
should use compression to read/write data to/from theRmiFile
- Specified by:
setUseCompression
in interfaceHecFile
- Parameters:
compress
-- See Also:
-
unlockFile
Description copied from interface:HecFile
Unlock this file with fLock.- Specified by:
unlockFile
in interfaceHecFile
- Parameters:
fLock
-- Returns:
- See Also:
-
writeBytes
public void writeBytes(long bytePos, byte[] bytes) - Specified by:
writeBytes
in interfaceHecFile
-
writeFloat
public void writeFloat(long bytePos, float f) Description copied from interface:HecFile
Write a float f to position bytePos in this HecFile.- Specified by:
writeFloat
in interfaceHecFile
- Parameters:
bytePos
-f
-- See Also:
-