X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Fsource%2FFileSource.java;h=3d6e871903a063ba7babd937e1a216ed5733a634;hb=7188da95cfb6dc2bf140eb8ac7e4dc99a0761a97;hp=010eeb9b773c85829804a307f124aad046d0a781;hpb=3d073631242b121378ff9c60104170d13cab52d7;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java b/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java index 010eeb9..3d6e871 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java +++ b/src/main/java/net/pterodactylus/sonitus/data/source/FileSource.java @@ -17,7 +17,7 @@ package net.pterodactylus.sonitus.data.source; -import static com.google.common.base.Preconditions.*; +import static com.google.common.base.Preconditions.checkNotNull; import static net.pterodactylus.sonitus.data.Metadata.UNKNOWN_CHANNELS; import static net.pterodactylus.sonitus.data.Metadata.UNKNOWN_ENCODING; import static net.pterodactylus.sonitus.data.Metadata.UNKNOWN_FREQUENCY; @@ -33,10 +33,10 @@ import net.pterodactylus.sonitus.data.Source; import net.pterodactylus.sonitus.io.IdentifyingInputStream; import com.google.common.base.Optional; -import com.google.common.io.ByteStreams; /** - * A {@link Source} that is read from the local file system. + * A {@link net.pterodactylus.sonitus.data.Source} that is read from the local + * file system. * * @author David ‘Bombe’ Roden */ @@ -56,7 +56,7 @@ public class FileSource implements Source { * * @param path * The path of the file - * @throws IOException + * @throws java.io.IOException * if the file can not be found, or an I/O error occurs */ public FileSource(String path) throws IOException { @@ -78,20 +78,20 @@ public class FileSource implements Source { // @Override - public Metadata metadata() { - return metadata; - } - - @Override public byte[] get(int bufferSize) throws IOException { byte[] buffer = new byte[bufferSize]; - int read = ByteStreams.read(fileInputStream, buffer, 0, bufferSize); - if (read == 0) { + int read = fileInputStream.read(buffer); + if (read == -1) { throw new EOFException(); } return Arrays.copyOf(buffer, read); } + @Override + public Metadata metadata() { + return metadata; + } + // // OBJECT METHODS //