Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support try-with-resources in Java 7+ for YamlWriter and YamlReader #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/com/esotericsoftware/yamlbeans/YamlReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.esotericsoftware.yamlbeans.scalar.ScalarSerializer;
import com.esotericsoftware.yamlbeans.tokenizer.Tokenizer.TokenizerException;

import java.io.Closeable;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
Expand All @@ -42,7 +43,7 @@

/** Deserializes Java objects from YAML.
* @author <a href="mailto:[email protected]">Nathan Sweet</a> */
public class YamlReader {
public class YamlReader implements Closeable {
private final YamlConfig config;
Parser parser;
private final Map<String, Object> anchors = new HashMap();
Expand Down Expand Up @@ -430,4 +431,4 @@ public static void main (String[] args) throws Exception {
YamlReader reader = new YamlReader(new FileReader("test/test.yml"));
System.out.println(reader.read());
}
}
}
3 changes: 2 additions & 1 deletion src/com/esotericsoftware/yamlbeans/YamlWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.esotericsoftware.yamlbeans;

import java.io.Closeable;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Array;
Expand Down Expand Up @@ -46,7 +47,7 @@

/** Serializes Java objects as YAML.
* @author <a href="mailto:[email protected]">Nathan Sweet</a> */
public class YamlWriter {
public class YamlWriter implements Closeable {
private final YamlConfig config;
private final Emitter emitter;
private boolean started;
Expand Down