Results 1 to 2 of 2
Thread: Concatenation file contents
-
Concatenation file contents
The readFile(...) method presented below reads a file and returns the string with the content. We have used StringBuffer to perform concatenation operations.
Java Code:private static String readFile(String filename) throws IOException { String lineSep = System.getProperty("line.separator"); BufferedReader br = new BufferedReader(new FileReader(filename)); String nextLine = ""; StringBuffer sb = new StringBuffer(); while ((nextLine = br.readLine()) != null) { sb.append(nextLine); sb.append(lineSep); } return sb.toString(); }
- 02-07-2008, 01:29 PM #2
Member
- Join Date
- Jan 2008
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Viewing contents of zip file
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 05:16 PM -
Adding file contents to Choice component
By Java Tip in forum Java TipReplies: 0Last Post: 02-07-2008, 09:06 AM -
Reading file contents (BufferedReader)
By Java Tip in forum Java TipReplies: 0Last Post: 02-07-2008, 09:00 AM -
Viewing contents of JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 12-21-2007, 03:12 PM -
viewing the contents of a text file in JTextArea
By warship in forum New To JavaReplies: 0Last Post: 07-17-2007, 02:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks