Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I am trying to figure out how to read a text file and read it into a text area in my program. This should be fairly straight forward but I can't seem to get anything to work. This doesn't work and I have tried several variations.
File filename = jfc.getSelectedFile(); try{// opens try FileReader in = new FileReader(filename); BufferedReader br = new BufferedReader(in); int c; String s = br.read(); while ((c = in.read()) != -1) br.write(c); comments.append("\n" + s +"\n"); in.close(); br.close(); }// closes try
I'm not sure what you're doing here, but surely "br.write(c)" is wrong if br is a BufferedReader. The compiler should complain. [ August 20, 2002: Message edited by: Ron Newman ]
Enjoy, pass a string as the filepath, then get the contents of the file via getFileContent() which returns a stringbuffer. To create a string call the toString() of the stringbuffer object. This code is really fast !!
[ August 20, 2002: Message edited by: Mark Nicholas ] [ Edited by Dave to format code ] [ August 20, 2002: Message edited by: David O'Meara ]