|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.File
com.antelmann.io.IniFile
public class IniFile
a file that loads properties to standard *.ini conventions
(unlike the class java.util.Properties)
| Field Summary | |
|---|---|
protected String |
charset
uses the default charset of this Java virtual machine by default |
protected char[] |
commentIndicator
uses '#', ';' and '[' by default, the array must never be empty |
protected String |
fieldSeparator
uses the equal sign '=' by default |
| Fields inherited from class java.io.File |
|---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
| Constructor Summary | |
|---|---|
IniFile(File file)
|
|
IniFile(File file,
String charset)
|
|
| Method Summary | |
|---|---|
void |
addProperty(String key,
String value)
|
protected boolean |
isCommentLine(String line)
checks whether the line is considered a comment. |
protected String[] |
parseLine(String line)
returns either null or an array of size 2, containing key/value pair. |
Properties |
readCascadingBasedOnFileNameProperty(String fileProperty)
the properties are read recursively where the given fileProperty is treated as the file name for a parent IniFile. |
Properties |
readProperties()
|
static Properties |
readProperties(InputStream in)
uses default values for comment indicators and field separators |
static Properties |
readProperties(InputStream in,
String charset)
uses default values for comment indicators and field separators |
boolean |
removeProperty(String property)
reads the complete file into memory, removes only the given property line (if it existed) and writes the content back to the file. |
boolean |
replaceProperty(String property,
String newValue)
|
boolean |
replaceProperty(String property,
String newProperty,
String newValue)
reads the complete file into memory, replaces only the given property line (if it existed) and writes the content back to the file. |
IniFile |
setCommentIndicator(char... commentIndicator)
returns this |
IniFile |
setFieldSeparator(String fieldSeparator)
returns this |
void |
store(Properties props,
String comment)
|
void |
writeProperties(Properties props)
|
| 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, toString, toURI, toURL |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String fieldSeparator
protected char[] commentIndicator
protected String charset
| Constructor Detail |
|---|
public IniFile(File file)
public IniFile(File file,
String charset)
| Method Detail |
|---|
public IniFile setFieldSeparator(String fieldSeparator)
public IniFile setCommentIndicator(char... commentIndicator)
public void writeProperties(Properties props)
throws IOException
IOException
public Properties readProperties()
throws IOException
IOException
public static Properties readProperties(InputStream in)
throws IOException
IOException
public static Properties readProperties(InputStream in,
String charset)
throws IOException
IOException
public Properties readCascadingBasedOnFileNameProperty(String fileProperty)
throws IOException
IOExceptionprotected String[] parseLine(String line)
isCommentLine(String)protected boolean isCommentLine(String line)
commentIndicator.
public void store(Properties props,
String comment)
throws IOException
IOException
public boolean replaceProperty(String property,
String newValue)
throws IOException
IOException
public boolean replaceProperty(String property,
String newProperty,
String newValue)
throws IOException
IOException
public void addProperty(String key,
String value)
throws IOException
IOException
public boolean removeProperty(String property)
throws IOException
IOException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||