Package de.elo.ix.jscript
Class FileBase
java.lang.Object
de.elo.ix.jscript.FileBase
This class declares the methods supported by both DiscFile and HttpFile.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyAllBytes
(FileBase destFile) Copy the content of this file to the given destination file.copyAllText
(FileBase destFile) Copy the contents of this file to the given destination file.Character set resp.boolean
isUseBom()
Handle Byte Order Mark.byte[]
Read all bytes from the file.Read the entire content from a text file.void
setCharset
(String charset) Character set resp.void
setUseBom
(boolean useBom) Handle Byte Order Mark Default value is false.byte[]
writeAllBytes
(byte[] buf) Write all bytes into a file.writeAllText
(String text) Write text into a file.
-
Constructor Details
-
FileBase
public FileBase()
-
-
Method Details
-
copyAllBytes
Copy the content of this file to the given destination file. The content is assumed to be in binary format and therfore no character set transformation is performed.- Parameters:
destFile
- Destination file- Returns:
- If this is a HttpFile, the server response is returned. Otherwise the return value is null.
- Throws:
IOException
-
copyAllText
Copy the contents of this file to the given destination file.- Parameters:
destFile
- Destination file- Returns:
- If this is a HttpFile, the server response is returned. Otherwise the return value is null.
- Throws:
IOException
-
readAllBytes
Read all bytes from the file.- Returns:
- Content as byte array.
- Throws:
IOException
-
readAllText
Read the entire content from a text file.- Returns:
- Text content
- Throws:
IOException
-
writeAllBytes
Write all bytes into a file.- Parameters:
buf
- Content as byte array.- Returns:
- depends on the implementing class
- Throws:
IOException
-
writeAllText
Write text into a file.- Parameters:
text
- Text content- Returns:
- depends on the implementing class
- Throws:
IOException
-
getCharset
Character set resp. encoding type for HttpFile. The default character set to be used is UTF-8.- Returns:
- Character set or null or empty. If null or empty, the default character set of the operating system is used.
-
setCharset
Character set resp. encoding type for HttpFile. The default character set to be used is UTF-8.- Parameters:
charset
- Character set or null or empty. If null or empty, the default character set of the operating system is used.
-
isUseBom
public boolean isUseBom()Handle Byte Order Mark. Default value is false.- Returns:
- true, if Byte Order Mark has to be detected on read and has to be prefixed on write.
-
setUseBom
public void setUseBom(boolean useBom) Handle Byte Order Mark Default value is false.- Parameters:
useBom
- true, if Byte Order Mark has to be detected on read and has to be prefixed on write.
-