Skip to content

Commit 2be2d50

Browse files
committed
Added a getIniMap() method and test
1 parent 3114db4 commit 2be2d50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/com/nikhaldimann/inieditor/IniEditor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public class IniEditor {
120120
private char[] commentDelims;
121121
private boolean isCaseSensitive;
122122
private OptionFormat optionFormat;
123+
private String iniName = null;
123124

124125
/**
125126
* Constructs new bare IniEditor instance.
@@ -242,6 +243,13 @@ public void setOptionFormatString(String formatString) {
242243
this.optionFormat = new OptionFormat(formatString);
243244
}
244245

246+
/**
247+
* Returns the name of the INI file if it exists, or null otherwise.
248+
*/
249+
public String getName() {
250+
return iniName;
251+
}
252+
245253
/**
246254
* Returns the value of a given option in a given section or null if either
247255
* the section or the option don't exist. If a common section was defined
@@ -530,6 +538,7 @@ public void save(OutputStreamWriter streamWriter) throws IOException {
530538
* @throws IOException at an I/O problem
531539
*/
532540
public void load(String filename) throws IOException {
541+
iniName = filename;
533542
load(new File(filename));
534543
}
535544

@@ -542,6 +551,7 @@ public void load(String filename) throws IOException {
542551
* @throws IOException at an I/O problem
543552
*/
544553
public void load(File file) throws IOException {
554+
iniName = file.getName();
545555
InputStream in = new FileInputStream(file);
546556
load(in);
547557
in.close();

0 commit comments

Comments
 (0)