Results 1 to 2 of 2
  1. #1
    lgafreitas is offline Member
    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Red face get a token's first character's position in a file

    Hi guys. I've been working on a plugin for eclipse as part of an internship, but since im relatively new to java I decided to post it here, hope it was the right decision. :)

    I've got a CommonTree with the parsed tokens (org.antlr.runtime.Token) to the contents of an editor. Would you guys know how I can get a tokens's first character's position counting from the beginning of the file/ input stream as opposed to the beginning of its line (as you could get by calling
    Java Code:
     token.getCharPositionInLine()
    ???

    Thanks a lot and again, I hope I've chosen the right place o post this :)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default

    how I can get a tokens's first character's position counting from the beginning of the file
    Read the bytes of the file vs reading the lines of the file. Then scan those bytes. Or if the contents of the file is text, you could create a String from the file's bytes and use the String class's methods.

Similar Threads

  1. spliting a string and checking each token's format
    By Implode in forum New To Java
    Replies: 1
    Last Post: 10-18-2009, 09:41 PM
  2. get position in string from caret position
    By helloworld111 in forum AWT / Swing
    Replies: 5
    Last Post: 02-19-2009, 02:36 AM
  3. BorderFactory to set position?
    By aleplgr in forum AWT / Swing
    Replies: 2
    Last Post: 01-30-2008, 01:46 PM
  4. Help with position in java
    By fernando in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 08:54 PM
  5. Use the mouse position
    By susan in forum Java Applets
    Replies: 1
    Last Post: 07-29-2007, 12:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •