diff options
author | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-09 16:22:54 +0000 |
---|---|---|
committer | trevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-09 16:22:54 +0000 |
commit | 7a9ecd262d5464d347c2035031f7a93447dc7bf6 (patch) | |
tree | 6ce5f08ec0c1b47c47c08c315e4c1a4177aa62eb /gi/posterior-regularisation/prjava/src/io | |
parent | 0caec27be906dd0d39e28aaed27d0932aa0d7b60 (diff) |
Added formal command line options & new main class.
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@200 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/io')
-rw-r--r-- | gi/posterior-regularisation/prjava/src/io/FileUtil.java | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/gi/posterior-regularisation/prjava/src/io/FileUtil.java b/gi/posterior-regularisation/prjava/src/io/FileUtil.java index 67ce571e..81e7747b 100644 --- a/gi/posterior-regularisation/prjava/src/io/FileUtil.java +++ b/gi/posterior-regularisation/prjava/src/io/FileUtil.java @@ -3,7 +3,24 @@ import java.util.*; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import java.io.*;
-public class FileUtil {
+public class FileUtil
+{
+ public static BufferedReader reader(File file) throws FileNotFoundException, IOException
+ {
+ if (file.getName().endsWith(".gz"))
+ return new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file))));
+ else
+ return new BufferedReader(new FileReader(file));
+ }
+
+ public static PrintStream printstream(File file) throws FileNotFoundException, IOException
+ {
+ if (file.getName().endsWith(".gz"))
+ return new PrintStream(new GZIPOutputStream(new FileOutputStream(file)));
+ else
+ return new PrintStream(new FileOutputStream(file));
+ }
+
public static Scanner openInFile(String filename){
Scanner localsc=null;
try
@@ -16,34 +33,6 @@ public class FileUtil { return localsc;
}
- public static BufferedReader openBufferedReader(String filename){
- BufferedReader r=null;
- try
- {
- if (filename.endsWith(".gz"))
- r=(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(new File(filename))))));
- else
- r=(new BufferedReader(new FileReader(new File(filename))));
- }catch(IOException ioe){
- System.out.println(ioe.getMessage());
- }
- return r;
- }
-
- public static PrintStream openOutFile(String filename){
- PrintStream localps=null;
- try
- {
- if (filename.endsWith(".gz"))
- localps=new PrintStream (new GZIPOutputStream(new FileOutputStream(filename)));
- else
- localps=new PrintStream (new FileOutputStream(filename));
-
- }catch(IOException ioe){
- System.out.println(ioe.getMessage());
- }
- return localps;
- }
public static FileInputStream openInputStream(String infilename){
FileInputStream fis=null;
try {
|