안드로이드 개발 질문/답변
(글 수 45,052)
File folder = new File(저장폴더);
if(!folder.exists()){
folder.mkdirs();
}
File file = new File(저장파일(경로+파일명));
try{
URL url = new URL("웹경로+파일명);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ((current = bis.read()) != -1) {
Log.i("tag","current : " + current);
baf.append((byte) current); // while문에서 빠져나와야 하는데 빠져나오질 못하네요 ㅜ.ㅜ
}
FileOutputStream fos = openFileOutput(file.toString(), 0);
//FileOutputStream fos = new FileOutputStream(file);
Log.i("tag","1111111111111111");
fos.write(baf.toByteArray());
Log.i("tag","2222222222222222");
//bis.close();
fos.close();
Log.i("tag","3333333333333333");
}catch(Exception e){
}
파일을 저장시키려고 합니다.
목적은 여러개의 사운드와 이미지 파일을 sd카드에 저장하려고 하는데요...
우선 파일이 하나라도 받아져야 뭘 할텐데 -0-;;;
후,,, 몇일짼지 모르겠네요 ㅜ.ㅜ
왜 while문에서 빠져나오지 못하는걸까요? ㅜ.ㅜ 해답좀 부탁드릴게요 ㅜ.ㅜ




while((current = bis.read()) != -1) current가 -1이 아닌 동안 계속 돌리는거니까, 조건이 되면 current가 -1이 되는건가요?