Commit 05702b6c authored by Daniel Le Berre's avatar Daniel Le Berre

Closing properly fwriter without using java7+ try on resources.

parent 15bd4355
......@@ -22,28 +22,33 @@ import org.sat4j.tools.encoding.Policy;
*/
public class OpbToDimacsWriter {
public static void main(String args[]) throws ParseFormatException,
IOException, ContradictionException {
public static void main(String args[])
throws ParseFormatException, IOException, ContradictionException {
new OpbToDimacsWriter(args);
}
public OpbToDimacsWriter(String[] args) throws ParseFormatException,
IOException, ContradictionException {
Set<EncodingStrategy> tabooEncodings = new HashSet<EncodingStrategy>();
public OpbToDimacsWriter(String[] args)
throws ParseFormatException, IOException, ContradictionException {
Set<EncodingStrategy> tabooEncodings = new HashSet<>();
tabooEncodings.add(EncodingStrategy.NATIVE);
for (EncodingStrategy strategy : EncodingStrategy.values()) {
if (tabooEncodings.contains(strategy))
continue;
DimacsStringSolver dss = new DimacsStringSolver();
IPBSolver solver = new ClausalConstraintsDecorator(new PBAdapter(
dss), Policy.getAdapterFromEncodingName(strategy));
OPBReader2012 reader = new OPBReader2012(new PBSolverHandle(solver));
IPBSolver solver = new ClausalConstraintsDecorator(
new PBAdapter(dss),
Policy.getAdapterFromEncodingName(strategy));
OPBReader2012 reader = new OPBReader2012(
new PBSolverHandle(solver));
solver.setVerbose(false);
reader.parseInstance(args[0]);
FileWriter fwriter = new FileWriter(args[0] + ".cardEncoding."
+ strategy.name() + ".cnf");
fwriter.write(dss.toString());
fwriter.close();
FileWriter fwriter = new FileWriter(
args[0] + ".cardEncoding." + strategy.name() + ".cnf");
try {
fwriter.write(dss.toString());
} finally {
fwriter.close();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment