diff options
Diffstat (limited to 'code/FORTRAN2C/fortran2c/CWriter.java')
-rw-r--r-- | code/FORTRAN2C/fortran2c/CWriter.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/code/FORTRAN2C/fortran2c/CWriter.java b/code/FORTRAN2C/fortran2c/CWriter.java new file mode 100644 index 0000000..fec748a --- /dev/null +++ b/code/FORTRAN2C/fortran2c/CWriter.java @@ -0,0 +1,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"); + } + } +} |