에서 EPUB 파일을 다운로드 할 수 있습니다 :어떻게 내가 같은 것을 할 노력하고있어 바이트 배열
public void onClick(View v) {
WebServiceC webService = WebServiceC();
epubDownloaded = webService.downloadEpub(publi.getId());
File fileEpub=new File(Environment.getExternalStorageDirectory(), "test.epub");
if (fileEpub.exists()) {
fileEpub.delete();
}
try {
FileOutputStream fos=new FileOutputStream(arquivoEpub.getPath());
fos.write(epubDownloaded);
fos.close();
}catch (IOException e) {
e.printStackTrace();
}
}
});
을하지만 그것은 작동하지 않습니다.
FATAL EXCEPTION : 메인 java.lang.NullPointerException이 java.io.OutputStream.write (OutputStream.java:82)
에서 ------------- -----------------------편집하다-------------------------- ---------------- 감사합니다 .. 나는 내 문제 이런 식으로 해결 ->
int count;
WebServiceC webService = new WebServiceC();
epubDownloaded = webService.downloadEpub(publi.getId());
InputStream input = new ByteArrayInputStream(epubDownloaded);
OutputStream output = null;
try {
output = new FileOutputStream(Environment.getExternalStorageDirectory()+"/test.epub");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte data[] = new byte[1024];
try {
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
감사합니다. 이제 작업 내용이 변경되었습니다. – rnnhma