Moved MPRIS to a new project
[stereo.git] / DAAPLib / src / util / command / Song.java
blob840b838be06472b7379e8752620f30ac8dca665d
1 package util.command;
3 import java.io.ByteArrayOutputStream;
4 import java.io.IOException;
5 import java.io.InputStream;
7 import api.Response;
9 public class Song extends Response {
11 private final byte[] song;
13 public Song(byte[] song) {
14 super(null, Response.OK);
16 this.song = song;
19 public Song(InputStream in, int length) throws IOException {
20 super(null, Response.OK);
22 ByteArrayOutputStream str = new ByteArrayOutputStream(length);
23 byte[] buf = new byte[256];
24 while (true) {
25 int read = in.read(buf, 0, 256);
26 if (read > 0) str.write(buf, 0, read);
27 else if (read == -1) break;
30 song = str.toByteArray();
33 public byte[] song() {
34 return song;