<commit_before>package toxi.geom.util;

import java.io.FileOutputStream;
import java.io.PrintWriter;

import toxi.geom.Vec3D;

/**
 * Extremely bare bones Wavefront OBJ 3D format exporter. Purely handles the
 * writing of data to the .obj file, but does not have any form of mesh
 * management. See {@link TriangleMesh} for details.
 * 
 * Needs to get some more TLC in future versions.
 * 
 * @author toxi
 * @see TriangleMesh#saveAsOBJ(OBJWriter)
 */
public class OBJWriter {

    public final String VERSION = "0.3";

    protected FileOutputStream objStream;
    protected PrintWriter objWriter;

    protected int numVerticesWritten = 0;
    protected int numNormalsWritten = 0;

    public void beginSave(String fn) {
        try {
            objStream = new FileOutputStream(fn);
            objWriter = new PrintWriter(objStream);
            objWriter.println("# generated by OBJExport v" + VERSION);
            numVerticesWritten = 0;
            numNormalsWritten = 0;
        } catch (Exception e) {
            // TODO don't catch all, but use custom exception for this
            e.printStackTrace();
        }
    }

    public void endSave() {
        try {
            objWriter.flush();
            objWriter.close();
            objStream.flush();
            objStream.close();
        } catch (Exception e) {
            e.printStackTrace();<commit_msg>minor change to endSave(): catching IOException only<commit_after>package toxi.geom.util;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;

import toxi.geom.Vec3D;

/**
 * Extremely bare bones Wavefront OBJ 3D format exporter. Purely handles the
 * writing of data to the .obj file, but does not have any form of mesh
 * management. See {@link TriangleMesh} for details.
 * 
 * Needs to get some more TLC in future versions.
 * 
 * @author toxi
 * @see TriangleMesh#saveAsOBJ(OBJWriter)
 */
public class OBJWriter {

    public final String VERSION = "0.3";

    protected FileOutputStream objStream;
    protected PrintWriter objWriter;

    protected int numVerticesWritten = 0;
    protected int numNormalsWritten = 0;

    public void beginSave(String fn) {
        try {
            objStream = new FileOutputStream(fn);
            objWriter = new PrintWriter(objStream);
            objWriter.println("# generated by OBJExport v" + VERSION);
            numVerticesWritten = 0;
            numNormalsWritten = 0;
        } catch (Exception e) {
            // TODO don't catch all, but use custom exception for this
            e.printStackTrace();
        }
    }

    public void endSave() {
        try {
            objWriter.flush();
            objWriter.close();
            objStream.flush();
            objStream.close();
        } catch (IOException e) {
            e.printStackTrace();
{'fraction_non_alphanumeric': 0.0871413390010627, 'fraction_numerical': 0.005667729365922777, 'mean_word_length': 2.39015606242497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4109518', 'n_tokens_mistral': 800, 'n_tokens_neox': 758, 'n_words': 251}