I have a mp3 that i would like to play and save, i can play it without problems, but i can't save it.
byte[] buffer = new byte[CHUNK_SIZE];
int bytesRead;
try (InputStream is = conn.getInputStream()) {
try (FileOutputStream fos = new FileOutputStream("output2.mp3")) {
while ((bytesRead = is.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead);
}
}
}
byte[] buffer = new byte[CHUNK_SIZE];
int bytesRead;
try (InputStream is = conn.getInputStream()) {
try (FileOutputStream fos = new FileOutputStream(new FileOutputStream(new File("H:\\TestFolder2\\test.mp3")) {
while ((bytesRead = is.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead);
}
}
}
This doesnt work as well!