summaryrefslogtreecommitdiffstats
path: root/code/FORTRAN2C/fortran2c/CWriter.java
blob: fec748a9d731508cc136f41cffaf9b11565150c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package fortran2c;

import java.io.*;
import java.util.HashSet;

public class CWriter {
    
    private String filePath;
    private File theFile;
    private FileWriter theFileWriter;
    private HashSet<String> functions;

    public CWriter(String filePath) throws IOException {
        this.filePath = filePath;
        File theFile = new File(filePath);

        if (theFile.createNewFile()) {
            FileWriter theFileWriter = new FileWriter(filePath);
            theFileWriter.write("#include <stdio.h>\n#include <stdlib.h>\n\nint main(int argc, char** argv) {\n}");
            theFileWriter.close();
            functions.add("main");
        } else {
            throw new IOException("The file already exists");
        }
    }
}