| 87 | /// Wraps a File as a Data object. |
| 88 | /// |
| 89 | class FileData implements Data { |
| 90 | private final File file; |
| 91 | |
| 92 | /// Creates a new Data wrapper for a file. |
| 93 | /// |
| 94 | /// #### Parameters |
| 95 | /// |
| 96 | /// - `file`: The file to be wrapped. |
| 97 | public FileData(File file) { |
| 98 | this.file = file; |
| 99 | } |
| 100 | |
| 101 | /// {@inheritDoc } |
| 102 | @Override |
| 103 | public void appendTo(OutputStream output) throws IOException { |
| 104 | FileSystemStorage fs = FileSystemStorage.getInstance(); |
| 105 | Util.copyNoClose(fs.openInputStream(file.getAbsolutePath()), output, 8192); |
| 106 | } |
| 107 | |
| 108 | /// {@inheritDoc } |
| 109 | @Override |
| 110 | public long getSize() throws IOException { |
| 111 | return file.length(); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /// Wraps a Storage object as a Data object. |
| 116 | /// |
nothing calls this directly
no outgoing calls
no test coverage detected