Skip to content

Commit 7e5a397

Browse files
committed
IOUtils moved to bg-commons
git-svn-id: https://bg.upf.edu/svn/gitools/trunk@912 1b512f91-3386-4a98-81e7-b8836ddf8916
1 parent 0c4e821 commit 7e5a397

File tree

5 files changed

+43
-66
lines changed

5 files changed

+43
-66
lines changed

gitools-core/src/main/java/org/gitools/utils/IOUtils.java renamed to bg-commons/src/main/java/edu/upf/bg/fileutils/IOUtils.java

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package org.gitools.utils;
1+
package edu.upf.bg.fileutils;
22

3+
import java.io.BufferedOutputStream;
34
import java.io.BufferedReader;
45
import java.io.BufferedWriter;
56
import java.io.File;
@@ -16,7 +17,6 @@
1617
import java.io.Reader;
1718
import java.io.Writer;
1819
import java.nio.ByteBuffer;
19-
import java.nio.channels.Channel;
2020
import java.nio.channels.Channels;
2121
import java.nio.channels.FileChannel;
2222
import java.nio.channels.ReadableByteChannel;
@@ -26,40 +26,58 @@
2626

2727
public class IOUtils {
2828

29-
public static Reader openReader(File path) throws FileNotFoundException, IOException {
29+
public static Reader openReader(File path) throws IOException {
3030
if (path == null)
3131
return null;
32-
32+
3333
if (path.getName().endsWith(".gz"))
3434
return
3535
new InputStreamReader(
3636
new GZIPInputStream(
3737
new FileInputStream(path)));
3838
else
39-
return
39+
return
4040
new BufferedReader(
4141
new FileReader(path));
4242
}
43-
44-
public static Writer openWriter(File path) throws FileNotFoundException, IOException {
43+
44+
public static Writer openWriter(File path) throws IOException {
4545
return openWriter(path, false);
4646
}
47-
48-
public static Writer openWriter(File path, boolean append) throws FileNotFoundException, IOException {
47+
48+
public static Writer openWriter(File path, boolean append) throws IOException {
4949
if (path == null)
5050
return null;
51-
51+
5252
if (path.getName().endsWith(".gz"))
5353
return
5454
new OutputStreamWriter(
5555
new GZIPOutputStream(
5656
new FileOutputStream(path, append)));
5757
else
58-
return
58+
return
5959
new BufferedWriter(
6060
new FileWriter(path, append));
6161
}
6262

63+
public static OutputStream openOutputStream(File path) throws IOException {
64+
return openOutputStream(path, false);
65+
}
66+
67+
public static OutputStream openOutputStream(File path, boolean append) throws IOException {
68+
if (path == null)
69+
return null;
70+
71+
if (path.getName().endsWith(".gz"))
72+
return
73+
new GZIPOutputStream(
74+
new FileOutputStream(path, append));
75+
else
76+
return
77+
new BufferedOutputStream(
78+
new FileOutputStream(path, append));
79+
}
80+
6381
public static void copyFile(File sourceFile, File destFile) throws IOException {
6482
if (!destFile.exists()) {
6583
destFile.createNewFile();

deploy.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
mvn package install assembly:assembly -DskipTests=true
4+

gitools-core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
</dependency>
4646

4747
<dependency>
48-
<groupId>weka</groupId>
49-
<artifactId>weka</artifactId>
50-
<version>3.6.2</version>
48+
<groupId>weka</groupId>
49+
<artifactId>weka</artifactId>
50+
<version>3.6.2</version>
5151
</dependency>
5252
</dependencies>
5353

gitools-core/src/main/java/org/gitools/exporter/TextMatrixViewExporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import org.gitools.matrix.model.IMatrixView;
99
import org.gitools.matrix.model.element.IElementAttribute;
10-
import org.gitools.utils.IOUtils;
10+
import edu.upf.bg.fileutils.IOUtils;
1111

1212
public class TextMatrixViewExporter {
1313

gitools-core/src/main/java/org/gitools/persistence/PersistenceUtils.java

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,33 @@
11
package org.gitools.persistence;
22

3-
import java.io.BufferedOutputStream;
4-
import java.io.BufferedReader;
5-
import java.io.BufferedWriter;
3+
import edu.upf.bg.fileutils.IOUtils;
64
import java.io.File;
7-
import java.io.FileInputStream;
8-
import java.io.FileOutputStream;
9-
import java.io.FileReader;
10-
import java.io.FileWriter;
115
import java.io.IOException;
12-
import java.io.InputStreamReader;
136
import java.io.OutputStream;
14-
import java.io.OutputStreamWriter;
157
import java.io.Reader;
168
import java.io.Writer;
179
import java.util.regex.Pattern;
18-
import java.util.zip.GZIPInputStream;
19-
import java.util.zip.GZIPOutputStream;
2010

2111
public class PersistenceUtils {
2212

2313
public static Reader openReader(File path) throws IOException {
24-
if (path == null)
25-
return null;
26-
27-
if (path == null)
28-
return null;
29-
30-
if (path.getName().endsWith(".gz"))
31-
return
32-
new InputStreamReader(
33-
new GZIPInputStream(
34-
new FileInputStream(path)));
35-
else
36-
return
37-
new BufferedReader(
38-
new FileReader(path));
14+
return IOUtils.openReader(path);
3915
}
4016

4117
public static Writer openWriter(File path) throws IOException {
42-
return openWriter(path, false);
18+
return IOUtils.openWriter(path);
4319
}
4420

4521
public static Writer openWriter(File path, boolean append) throws IOException {
46-
if (path == null)
47-
return null;
48-
49-
if (path.getName().endsWith(".gz"))
50-
return
51-
new OutputStreamWriter(
52-
new GZIPOutputStream(
53-
new FileOutputStream(path, append)));
54-
else
55-
return
56-
new BufferedWriter(
57-
new FileWriter(path, append));
22+
return IOUtils.openWriter(path, append);
5823
}
5924

6025
public static OutputStream openOutputStream(File path) throws IOException {
61-
return openOutputStream(path, false);
26+
return IOUtils.openOutputStream(path);
6227
}
6328

6429
public static OutputStream openOutputStream(File path, boolean append) throws IOException {
65-
if (path == null)
66-
return null;
67-
68-
if (path.getName().endsWith(".gz"))
69-
return
70-
new GZIPOutputStream(
71-
new FileOutputStream(path, append));
72-
else
73-
return
74-
new BufferedOutputStream(
75-
new FileOutputStream(path, append));
30+
return IOUtils.openOutputStream(path, append);
7631
}
7732

7833
// Copied from http://stackoverflow.com/questions/204784/how-to-construct-a-relative-path-in-java-from-two-absolute-paths-or-urls

0 commit comments

Comments
 (0)