Package loci.common
Class IniParser
- java.lang.Object
-
- loci.common.IniParser
-
public class IniParser extends Object
A simple parser for INI configuration files. Supports pound (#) as comments, and backslash (\) to continue values across multiple lines.- Author:
- Curtis Rueden ctrueden at wisc.edu
-
-
Constructor Summary
Constructors Constructor Description IniParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BufferedReader
openTextResource(String path)
Opens a buffered reader for the given resource.static BufferedReader
openTextResource(String path, Class<?> c)
Opens a buffered reader for the given resource.IniList
parseINI(BufferedReader in)
Parses the INI-style configuration data from the given input stream.IniList
parseINI(File file)
Parses the INI-style wrapping the given file in aBufferedReader
IniList
parseINI(String path)
Parses the INI-style configuration data from the given resource.IniList
parseINI(String path, Class<?> c)
Parses the INI-style configuration data from the given resource, using the given class to find the resource.void
setBackslashContinuesLine(boolean slashContinues)
Set whether or not a '\' at the end of a line signifies that the line continues on the following line.void
setCommentDelimiter(String delimiter)
Set the String that identifies a comment.
-
-
-
Method Detail
-
setCommentDelimiter
public void setCommentDelimiter(String delimiter)
Set the String that identifies a comment. Defaults to "#".- Parameters:
delimiter
- the String used to identify comments
-
setBackslashContinuesLine
public void setBackslashContinuesLine(boolean slashContinues)
Set whether or not a '\' at the end of a line signifies that the line continues on the following line. By default, a '\' does continue the line.- Parameters:
slashContinues
- true if a '\' at the end of a line signifies that the line continues on the following line
-
parseINI
public IniList parseINI(String path) throws IOException
Parses the INI-style configuration data from the given resource.- Parameters:
path
- the name of the resource to read- Returns:
- the IniList parsed from the named resource
- Throws:
IOException
- if the resource cannot be read- See Also:
openTextResource(String)
-
parseINI
public IniList parseINI(String path, Class<?> c) throws IOException
Parses the INI-style configuration data from the given resource, using the given class to find the resource.- Parameters:
path
- the name of the resource to readc
- the Class to use for finding the named resource- Returns:
- the IniList parsed from the named resource
- Throws:
IOException
- if the resource cannot be read- See Also:
openTextResource(String, Class)
-
parseINI
public IniList parseINI(File file) throws IOException
Parses the INI-style wrapping the given file in aBufferedReader
- Parameters:
file
- the file on disk from which to read- Returns:
- the IniList parsed from the file
- Throws:
IOException
- if the file cannot be read
-
parseINI
public IniList parseINI(BufferedReader in) throws IOException
Parses the INI-style configuration data from the given input stream.- Parameters:
in
- the BufferedReader stream from which to read- Returns:
- the IniList parsed from the reader
- Throws:
IOException
- if the stream cannot be read
-
openTextResource
public static BufferedReader openTextResource(String path)
Opens a buffered reader for the given resource.- Parameters:
path
- the name of the resource to read- Returns:
- the BufferedReader corresponding to the named resource
- See Also:
openTextResource(String)
-
openTextResource
public static BufferedReader openTextResource(String path, Class<?> c)
Opens a buffered reader for the given resource.- Parameters:
path
- the name of the resource to readc
- the Class to use for finding the named resource- Returns:
- the BufferedReader corresponding to the named resource
- See Also:
openTextResource(String)
-
-