From 808aa98dfdc0f2beb42503172de61f72981d6735 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Fri, 9 Jul 2010 16:22:54 +0000 Subject: Added formal command line options & new main class. git-svn-id: https://ws10smt.googlecode.com/svn/trunk@200 ec762483-ff6d-05da-a07a-a48fb63a330f --- .../prjava/src/io/FileUtil.java | 47 +++++++++------------- 1 file changed, 18 insertions(+), 29 deletions(-) (limited to 'gi/posterior-regularisation/prjava/src/io') 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 { -- cgit v1.2.3