From 5517e0b82f9503c59c10fc0167fa9d7fbdca1e64 Mon Sep 17 00:00:00 2001 From: "trevor.cohn" Date: Wed, 7 Jul 2010 14:11:42 +0000 Subject: git-svn-id: https://ws10smt.googlecode.com/svn/trunk@173 ec762483-ff6d-05da-a07a-a48fb63a330f --- gi/posterior-regularisation/prjava/src/io/FileUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 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 7d9f2bc5..67ce571e 100644 --- a/gi/posterior-regularisation/prjava/src/io/FileUtil.java +++ b/gi/posterior-regularisation/prjava/src/io/FileUtil.java @@ -1,5 +1,7 @@ package io; import java.util.*; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; import java.io.*; public class FileUtil { public static Scanner openInFile(String filename){ @@ -18,7 +20,10 @@ public class FileUtil { BufferedReader r=null; try { - r=(new BufferedReader(new FileReader(new File(filename)))); + 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()); } @@ -29,7 +34,10 @@ public class FileUtil { PrintStream localps=null; try { - localps=new PrintStream (new FileOutputStream(filename)); + 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()); -- cgit v1.2.3