* if the file can not be found, or an I/O error occurs
*/
public FileSource(String path) throws IOException {
* if the file can not be found, or an I/O error occurs
*/
public FileSource(String path) throws IOException {
this.path = checkNotNull(path, "path must not be null");
fileInputStream = new FileInputStream(path);
/* identify file type. */
Optional<IdentifyingInputStream> identifyingInputStream = IdentifyingInputStream.create(new FileInputStream(path));
if (identifyingInputStream.isPresent()) {
this.path = checkNotNull(path, "path must not be null");
fileInputStream = new FileInputStream(path);
/* identify file type. */
Optional<IdentifyingInputStream> identifyingInputStream = IdentifyingInputStream.create(new FileInputStream(path));
if (identifyingInputStream.isPresent()) {
byte[] buffer = new byte[bufferSize];
int read = fileInputStream.read(buffer);
if (read == -1) {
throw new EOFException();
}
byte[] buffer = new byte[bufferSize];
int read = fileInputStream.read(buffer);
if (read == -1) {
throw new EOFException();
}
- return Arrays.copyOf(buffer, read);
- }
-
- @Override
- public Metadata metadata() {
- return metadata;
+ return new DataPacket(metadata(), Arrays.copyOf(buffer, read));