View Single Post
  #7 (permalink)  
Old 04-21-2008, 05:21 AM
Eranga's Avatar
Eranga Eranga is online now
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,601
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
I'm not sure how and why you going to use algorithms for this. In simple way you can read the file and get the numbers of each columns. As i said earlier, space in between two numbers of a each line is important for my application. I assumed that the space is two tabs.

Code:
FileInputStream fis = null; try { fis = new FileInputStream("files/ReadFileByLines.txt"); InputStreamReader isr = new InputStreamReader(fis); LineNumberReader lnr = new LineNumberReader(isr); String line = null; while((line = lnr.readLine()) != null){ StringTokenizer st1 = new StringTokenizer(line, "\t\t"); String s1 = st1.nextToken(); String s2 = st1.nextToken(); String s3 = st1.nextToken(); System.out.println(s1 + "\t" + s2 + "\t" + s3); } System.out.println("Total number of lines on the file " + "is " + lnr.getLineNumber()); } catch (IOException ex) { System.out.println(ex.getMessage()); } finally { try { fis.close(); } catch (IOException ex) { System.out.println(ex.getMessage()); } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote