1 | |
package org.jtheque.core.utils.file.jt; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.utils.file.jt.able.IJTFileReader; |
20 | |
import org.jtheque.core.utils.file.jt.able.JTFile; |
21 | |
import org.jtheque.utils.io.FileException; |
22 | |
|
23 | |
import java.io.BufferedInputStream; |
24 | |
import java.io.DataInputStream; |
25 | |
import java.io.File; |
26 | |
import java.io.FileInputStream; |
27 | |
import java.io.FileNotFoundException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public abstract class JTFileReader implements IJTFileReader { |
35 | |
@Override |
36 | |
public final JTFile readFile(File file) throws FileException { |
37 | |
try { |
38 | 0 | return readFile(new FileInputStream(file)); |
39 | 0 | } catch (FileNotFoundException e) { |
40 | 0 | throw new FileException("File not found", e); |
41 | |
} |
42 | |
} |
43 | |
|
44 | |
@Override |
45 | |
public final JTFile readFile(String path) throws FileException { |
46 | 0 | return readFile(new File(path)); |
47 | |
} |
48 | |
|
49 | |
@Override |
50 | |
public final JTFile readFile(FileInputStream stream) throws FileException { |
51 | 0 | return readFile(new BufferedInputStream(stream)); |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public final JTFile readFile(BufferedInputStream stream) throws FileException { |
56 | 0 | return readFile(new DataInputStream(stream)); |
57 | |
} |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
protected abstract JTFile readFile(DataInputStream stream) throws FileException; |
67 | |
} |