Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 05:35 PM
Member
 
Join Date: Jul 2007
Posts: 44
simon is on a distinguished road
how to know the number of the line
I want to know the line number of the file.
My file's lines are variable length. And I want to learn the number of the line of the file without reading whole file line by line.
can you help me? please..
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-31-2007, 07:50 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
The only way to know the line number it to count the linefeeds (\n) in the document. Which means you have to read through the whole file to figure it out.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-01-2007, 05:37 PM
Member
 
Join Date: Jul 2007
Posts: 44
simon is on a distinguished road
uhh I don't like this answer
anyway, thanks
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-01-2007, 05:59 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Sorry no refunds.

One option is to keep an index of where each line begins in the file. Then you can tell where you are at based on the index. You can store the index in a different file or at the beginning of the file.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Line number: ? Azndaddy New To Java 1 04-04-2008 06:46 AM
how to use Scanner with a number cew27 New To Java 8 01-29-2008 07:22 AM
line number kazitula New To Java 3 11-21-2007 11:27 PM
Reading in data from file line by line bluekswing New To Java 1 10-02-2007 01:19 AM
Help with setting number as even or odd fegiflu New To Java 8 07-24-2007 07:07 PM


All times are GMT +3. The time now is 10:24 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org