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.managers.file.able.BasicDataSource; |
20 | |
import org.jtheque.core.utils.file.jt.able.IJTFileWriter; |
21 | |
import org.jtheque.utils.io.FileException; |
22 | |
|
23 | |
import java.io.BufferedOutputStream; |
24 | |
import java.io.DataOutputStream; |
25 | |
import java.io.File; |
26 | |
import java.io.FileNotFoundException; |
27 | |
import java.io.FileOutputStream; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public abstract class JTFileWriter implements IJTFileWriter { |
35 | |
@Override |
36 | |
public final void writeFile(File file, BasicDataSource source) throws FileException { |
37 | |
try { |
38 | 0 | writeFile(new FileOutputStream(file), source); |
39 | 0 | } catch (FileNotFoundException e) { |
40 | 0 | throw new FileException("File not found", e); |
41 | 0 | } |
42 | 0 | } |
43 | |
|
44 | |
@Override |
45 | |
public final void writeFile(String path, BasicDataSource source) throws FileException { |
46 | 0 | writeFile(new File(path), source); |
47 | 0 | } |
48 | |
|
49 | |
@Override |
50 | |
public final void writeFile(FileOutputStream stream, BasicDataSource source) throws FileException { |
51 | 0 | writeFile(new BufferedOutputStream(stream), source); |
52 | 0 | } |
53 | |
|
54 | |
@Override |
55 | |
public final void writeFile(BufferedOutputStream stream, BasicDataSource source) throws FileException { |
56 | 0 | writeFile(new DataOutputStream(stream), source); |
57 | 0 | } |
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
protected abstract void writeFile(DataOutputStream stream, BasicDataSource source) throws FileException; |
67 | |
} |