|
6 | 6 | import com.rumpf.proto.field.MessageField;
|
7 | 7 | import com.rumpf.proto.field.MessageFieldFactory;
|
8 | 8 |
|
9 |
| -import java.io.ByteArrayOutputStream; |
10 |
| -import java.io.IOException; |
11 |
| -import java.io.InputStream; |
12 |
| -import java.io.OutputStream; |
| 9 | +import java.io.*; |
13 | 10 | import java.lang.reflect.Constructor;
|
14 | 11 | import java.lang.reflect.InvocationTargetException;
|
15 | 12 | import java.nio.ByteBuffer;
|
@@ -72,6 +69,10 @@ public void write(Object object, ByteBuffer buffer) throws IOException {
|
72 | 69 | write(object, CodedOutputStream.newInstance(buffer));
|
73 | 70 | }
|
74 | 71 |
|
| 72 | + public void write(Object object, File file) throws IOException { |
| 73 | + write(object, new FileOutputStream(file)); |
| 74 | + } |
| 75 | + |
75 | 76 | public void write(Object object, OutputStream output) throws IOException {
|
76 | 77 | write(object, CodedOutputStream.newInstance(output));
|
77 | 78 | }
|
@@ -118,6 +119,14 @@ public <T> T read(ByteBuffer buf, Class<T> clazz) throws IOException {
|
118 | 119 | return read(CodedInputStream.newInstance(buf), clazz);
|
119 | 120 | }
|
120 | 121 |
|
| 122 | + public Object read(File source) throws IOException { |
| 123 | + return read(source, Object.class); |
| 124 | + } |
| 125 | + |
| 126 | + public <T> T read(File source, Class<T> clazz) throws IOException { |
| 127 | + return read(new FileInputStream(source), clazz); |
| 128 | + } |
| 129 | + |
121 | 130 | public Object read(InputStream input) throws IOException {
|
122 | 131 | return read(input, Object.class);
|
123 | 132 | }
|
|
0 commit comments