// Asset에 있는 번들 데이터(분할된 파일 형심)를 로컬 영역에 복사
// 분할된 파일은 file.1, file.2, file.3, file.x ...
// 위와 같은 형식으로 확장자 대신 번호가 붙어 있어야 한다.
public static boolean copyToLocal(Context c, final String assetName, final String toPath) {
int count = 1;
InputStream in = null;
FileOutputStream out = null;
try {
out = c.openFileOutput(toPath, Context.MODE_PRIVATE);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
while (out != null) {
// open src files
try {
in = c.getAssets().open(assetName + "." + String.valueOf(count));
}
catch (IOException e) {
in = null;
}
if (in == null) break;
// copy and merge
byte[] buff = new byte[1024];
int size = 0;
try {
while ((size = in.read(buff)) > 0)
out.write(buff, 0, size);
in.close();
}
catch (IOException e) {
e.printStackTrace();
return false;
}
++count;
}
try {
out.close();
}
catch (IOException e) {
e.printStackTrace();
}
return out != null;
}
'IT 연구회' 카테고리의 다른 글
[하둡] 독자모드 설치와 확인 (0) | 2014.03.07 |
---|---|
[하둡설치] starting hadoop (0) | 2014.03.07 |
xml (1) | 2014.03.01 |
Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace. (1) | 2013.12.23 |
이중 스크롤뷰(ScrollView)의 scroll 컨트롤하기 (0) | 2013.09.17 |
인텐트 (Intent) (0) | 2013.09.17 |
webview (0) | 2013.09.17 |
안드로이드 스레드 (handler) 핸들러 (0) | 2013.09.17 |
안드로이드 스레드2 핸들러(handler) (0) | 2013.09.17 |
listview (0) | 2013.09.17 |