파일을 받으려고합니다. inputstream을 얻어 문자열로 변환하여 내 메서드에 전달합니다. 거기에서 바이트 배열로 변환 한 다음 다시 파일로 변환하려고합니다. 나는이 결과를 얻을 수 없다. 이것은 파일에 문자열을 쓰는 방법입니다.자바 입력 스트림을 파일로 다시 문자열
String result = convertStreamToString(is);
byte[] b = result.getBytes();
FileOutputStream fos = null;
fos = new FileOutputStream("/sdcard/chats/ReceivedFile");
Log.i("IMSERVICE", "FILERECCC-1");
if (b!= null)
{
result = convertStreamToString(is);
result = result.replace("\n", "");
Log.e("InputStream output","FILEREC");
//IOUtils.copy(is,fos);
byte[] buffer = new byte[1024];
int length;
while ((length = b.length) > 0)
{
fos.write(buffer, 0, length);
}
아무도 도와 줄 수 있습니까?
나는 당신의 while 루프가 문제가 내 코드를 시도 만들 생각합니다. – user370305