안드로이드 개발 질문/답변
(글 수 45,052)
fos.write(selectedItem.get(i).getBytes()); 으로 파일을 첫줄 쓰고
줄바꿔서 fos.write(str.getBytes()); 쓰고 싶습니다.
주석처리 한 부분처럼 했는데 안되네요;;
바로 옆으로 이어져서 나옵니다.
줄바꿔서 fos.write(str.getBytes()); 쓰고 싶습니다.
주석처리 한 부분처럼 했는데 안되네요;;
바로 옆으로 이어져서 나옵니다.
public void saveFile(ArrayList<String> selectedItem){ String str = "TOTAL = "+num; //String nextLine = "\n"; try{
FileOutputStream fos = new FileOutputStream(Savingfile,true);
for(int i=0; i<=(selectedItem.size()-1); i++) { fos.write(selectedItem.get(i).getBytes()); //fos.newLine(); //fos.write(nextLine.getBytes()); fos.write(str.getBytes()); fos.close(); } }catch(FileNotFoundException e) { showMsg("지정된 파일을 생성할 수 없습니다."); } catch(IOException e) { e.printStackTrace(); } }
1. \n => \r\n 바꿔보세요
2. 메모장에서는 인식못하지만 에디터플러스 같은경우 인식할 수 있습니다.