int mBufferSize = 1024 * 25; //전역변수
public byte[] filebyte() {
byte[] data = new byte[mBufferSize];
byte buffer = 0;
byte[] output = new byte[mBufferSize];
try {
InputStream fres = m_Context.getResources().openRawResource(
R.raw.file100);
while ((buffer = (byte) fres.read(data, 0, data.length)) != -1) {;
} //☆
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
Log.d("DEBUG", "파일없음");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
Log.d("DEBUG", "예외처리");
e.printStackTrace();
}
return data;
}
file100이라는 100kB짜리 텍스트파일을 읽어오고있는데
read(buf,0,길이) 이 메서드가 텍스트파일 처음부터 길이만큼만 읽어오는 메서드 아닌가요?
저렇게 실행을 하게되면 파일의 처음이 아닌 중간부터 시작해 길이(1024*25)만큼만 버퍼에 들어가집니다..
파일 처음부터 원하는 사이즈만큼만 버퍼배열(data배열)에 넣고 싶은데 어떻게해야할까요?