요새 c#이랑 자바랑 병행해가며 공부하느라 바쁘다 ㅜㅜ
전체적인 흐름은 FileChooser를 통해 텍스트 파일을 열고 그 내용을
TextArea에 출력해주는거임.
fc.showOpenDialog(null);
try {
FileInputStream input;
BufferedReader fr = new BufferedReader(new FileReader(
fc.getSelectedFile().getPath()));
String str;
while((str=fr.readLine()) != null) {
np.getTa().setText(np.getTa().getText() + str + "\n");
}
}catch(IOException io) {
JOptionPane.showMessageDialog(null, io.getMessage());
}
여기서 내가 맘에 안드는건
np.getTa().setText(np.getTa().getText() + str + "\n"); <<<<<< 여기에 "\n"줄바꿈을 넣는다는거임.
이런 줄바꿈 같은거 없이 그냥 있는 그대로 쫙 가져와서 출력해주는 좋은 방법 없음?
5개의 댓글
무분별한 사용은 차단될 수 있습니다.
decltype
HIGH SIERRA
만약 readline말고 문자단위 또는 기타 방법으로 읽는다면 개행문자도 문자니깐 그대로 출력이 가능하다
타피
강간범
fileopen 다이얼로그로 filename 알아낸 다음에
filestream 클래스로 불러와라.
string str = new filestream(filename, fileinfo.open).readalllines()
문서가 길어서 중간중간 속도 제어를 해야한다면
read()함수로 byte를 디코딩 하는 방식을 쓰셈
브로리와 아청법
그런데 filestream 클래스로 불러들이라는게 FileInputStream 얘기하는거 맞지?
string str = new filestream(filename, fileinfo.open).readalllines() 여기에 FileStream이라는 클래스는 없고
FileInpuStream으로 하면 readAllLines라는 메소드가 없음.