summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/io
diff options
context:
space:
mode:
authortrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-07 14:11:42 +0000
committertrevor.cohn <trevor.cohn@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-07 14:11:42 +0000
commit5517e0b82f9503c59c10fc0167fa9d7fbdca1e64 (patch)
treea5ff0f26fc78627a52288fcabde843b4f0dfefc9 /gi/posterior-regularisation/prjava/src/io
parent946f7569a487209a35567e804d92edd1a84f2619 (diff)
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@173 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/io')
-rw-r--r--gi/posterior-regularisation/prjava/src/io/FileUtil.java12
1 files changed, 10 insertions, 2 deletions
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());