| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.galagosearch.tupleflow; |
| 5 | |
|
| 6 | |
import java.io.BufferedOutputStream; |
| 7 | |
import java.io.DataOutputStream; |
| 8 | |
import java.io.FileInputStream; |
| 9 | |
import java.io.FileOutputStream; |
| 10 | |
import java.io.IOException; |
| 11 | |
import java.io.RandomAccessFile; |
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | 0 | public class StreamCreator { |
| 18 | |
private static String stripPrefix(String filename) { |
| 19 | 0 | String[] fields = filename.split(":"); |
| 20 | 0 | if(fields.length > 1) |
| 21 | 0 | return filename.substring(fields[0].length() + 1); |
| 22 | |
|
| 23 | 0 | return filename; |
| 24 | |
} |
| 25 | |
|
| 26 | |
public static FileInputStream realInputStream(String filename) throws IOException { |
| 27 | 0 | FileInputStream stream = new FileInputStream(filename); |
| 28 | 0 | return stream; |
| 29 | |
} |
| 30 | |
|
| 31 | |
public static RandomAccessFile inputStream(String filename) throws IOException { |
| 32 | 0 | RandomAccessFile file = new RandomAccessFile(filename, "r"); |
| 33 | 0 | return file; |
| 34 | |
} |
| 35 | |
|
| 36 | |
public static RandomAccessFile outputStream(String filename) throws IOException { |
| 37 | 0 | RandomAccessFile file = new RandomAccessFile(filename, "rw"); |
| 38 | 0 | return file; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public static DataOutputStream realOutputStream(String filename) throws IOException { |
| 42 | 0 | DataOutputStream file = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename))); |
| 43 | 0 | return file; |
| 44 | |
} |
| 45 | |
} |