Line Counter?

Hi there,
I am trying to use Scanner to read a CSV file. I need to know how many lines there are in the file so I can create the right amount of elements for my array. We have not been taught how to use lists yet so that is what I am stuck with.
What is the best way to do this?
Thanks,

Hi Atholon,
I have some solutions for your problem.
Type 1: As you said read the file twice, first time get the count and second time read the data. Code is as below.
import java.io.*;
class FileTestReader
     public static void main(String[] args)
          System.out.println("File Reader");
          DataInputStream in = null;
          try
               // Open the file that is the first
               // command line parameter
               FileInputStream fstream = new FileInputStream("journal.txt");
               // Get the object of DataInputStream
               in = new DataInputStream(fstream);
               BufferedReader br = new BufferedReader(new InputStreamReader(in));
               String asd;
                    int count = 0;
                    //Read File Line By Line
                    while ((asd = br.readLine()) != null)  
                         count++;
                    System.out.println(count);
                    fstream = new FileInputStream("journal.txt");
                    // Get the object of DataInputStream
                    in = new DataInputStream(fstream);
                    br = new BufferedReader(new InputStreamReader(in));
                    //Read File Line By Line
                    while ((asd = br.readLine()) != null)  
                         //System.out.println(asd);
          }catch(Exception e)
               System.out.println(e);
          }finally
               try
                    //Close the input stream
                    in.close();
               catch(Exception e)
                    System.out.println(e);
}Type 2: Read once using Array List and transfer to String array. The code is as below.
import java.io.*;
import java.util.*;
class FileTestReader
     public static void main(String[] args)
          System.out.println("File Reader");
          DataInputStream in = null;
          try
               // Open the file that is the first
               // command line parameter
               FileInputStream fstream = new FileInputStream("journal.txt");
               // Get the object of DataInputStream
               in = new DataInputStream(fstream);
               BufferedReader br = new BufferedReader(new InputStreamReader(in));
               String asd;
                    int count = 0;
                    List ls = new ArrayList();
                    //Read File Line By Line
                    while ((asd = br.readLine()) != null)  
                         ls.add(asd);
                         count++;
                    System.out.println(count);
                    System.out.println(ls.size());
                    String outputStringArray[] = new String[ls.size()];
                    for(int i=0;i<ls.size();i++)
                         outputStringArray[i] = (String)ls.get(i);
                         System.out.println(ls.get(i));
          }catch(Exception e)
               System.out.println(e);
          }finally
               try
                    //Close the input stream
                    in.close();
               catch(Exception e)
                    System.out.println(e);
}Regards,
Zack

Similar Messages

  • Order of delivery schedule line counter at schedule agreements from MRP run

    Currently we are using schedule agreements for our long term external suppliers, but we are facing a problem with the order of new delivery schedule lines created during MRP run.
    Because of master data settings like, lot size, rounding value, plan delivery time and planning time fence to set as firm new requirements, multiple schedule lines are created with no order for schedule line counter.
    Does anyone is aware of a BADI, user exit or customizing control to have this schedule line counter in order?
    Thank you
    Daniel Guillen
    IT
    Skyworks Inc.

    Hi,
    Pls put this query in SD fourms  and get immly help because this is technical fourms.
    Anil

  • Multiple small stories with variable line counts assigned to different editors

    I have a "best practice" question for you more experienced InCopy users about what workflow you recommend for my specific issue. I am experienced in InDesign, but am a InCopy newbie. I want to make sure I'm not missing a solution because my lack of experience with InCopy may be causing me not to see the forest for the trees.
    Short version: What is the best way to allow multiple editors access to each of multiple small stories separately (one story per editor), but to allow the line count of each story to be variable each week, while adjusting the rest of the stories along with it on the page (see image below)?
    Details: My publishing company's workflow is on CS6 with editors working in Word, and we're upgrading to CC2014 with InCopy. We have 7 in-house editors, and all files on an in-house server. We have quick deadlines (some are 15 minutes from editor writing copy to transmitting publication to subscribers). In the example below, we have 10 sections, and I have all seven editors writing different sections at the same time. A final editor has control over fitting the final page. My INDD files to test the new workflow use an assignment-based workflow. I understand I can place each of these sections as their own story, under the same assignment, so a different editor can have them checked out. However, each section does not have the same line count from week to week. Markets with more activity will get more lines.
    In our current workflow, we have multiple rough Word docs pulled into one master doc with a script, that the final editor edits to fit, so each section can be a different number of lines as long as the total is the same. Then production staff load it in. When we upgrade, we can use a hybrid workflow where the final editor just loads that final Word doc into one InCopy story and edits it to fit.
    It would be great if I just didn't understand how to make the text height variable for the story each editor is typing, and auto-adjust so the next story starts below where the story above it ends, and you all had an idea how I can do it!
    Thanks! Nancy

    I disagree to Seshu's answer to question 1.
    Correct answer of question 1 is C and <u><b>not A.</b></u>
    Sorry I didn't find time to check the rest.
    <u>To the examinee</u>
    I wouldn't assume all answers from SDN-ers are correct if my certification exam was knocking the door! I would rather try and find out the correct answers myself from the system instead of mugging these answers without any understanding of the technology involved! Find out the answers yourself from the system...that way it will help you to understand why the answer is 'C' and not 'A'...just knowing the answer is 'C' is not good enough...one has to understand "why" its 'C' and not 'A'. Hope you get my point! Good luck.

  • Link between Delivery schedule line counter from PO and the material docume

    Dear Gurus,
    I have one PO with single line item having delivery schedule -
    Material 1 -
    delivery schedule 01.01.2009     2000
                                                         01.03.2009    5000
    I have received quantity against this Po
    I want to know where I can find the link between Delivery schedule line counter from PO and the material document
    Best regards
    Sar

    There is no link from the MAterial document line item (Table Mseg) to the PO Schedule Line (EKET).
    If this is for Evaluating an on time delivery or GR, you may consider the following approach.
    PO details Po Date  QTY
    Sch1   01Jun2009   200   
    SCH2  08Jun2009   100
    GR Details
    GR1   01Jun2009   180
    GR2   07Jun2009   110
    GR3  09Jun2009      10
    Calculate a *** total qty for the PO Line.
    PO details Po Date  CUMUL QTY
    Sch1   01Jun2009   200   
    SCH2  08Jun2009   300
    Calculate a *** total qty for the ontime GR.
    PO details Po Date  CUMUL PO QTY  CUMUL GR on time
    Sch1   01Jun2009   200                180
    SCH2  08Jun2009   300                 290 (180+110)  the 3rd GR was too late
    Evaluate the PO SChedule Lines as follows:
    Po SCL qty + CUMUL GR QTY - CUMUL PO QTY = ADJ GR ON Time Qty
    SCH1 01Jun2009
    200 + 180 - 200 = 180 on time for 01Jun2009 date ( 90% fill rate)
    SCH2 08Jun2009
    100 + 290 - 300 = 90 on time for 08Jun2009 date (90 % fill rate) the first 20 of the GR on 07Jun2009 went to fill the late, early date.
    Best of luck !
    SCH2 100 +290 - 300 = 90 on time for 07Jun2009 date

  • Report:Setting the line-count in the output automatically

    i want to set the line-count in the report automatically irrespective of screen resolution.could you please explain.

    hi,
    try this,
    report zrich_0001  line-count 25(4).
    reward points if useful,
    regards,
    Raj,

  • Varying the line count in every page

    Hi All..
    I want to vary the line count in a page in my report.
    I have mentioned the line size n line count at the starting of the report, n it prints the same no of lines in every page but in the subsequent pages , I want to increase the line count .
    How can I do that ? 
    Thanks.

    Hi Naimesh..
    thanks for the reply .
    well,the code u suggested does not work..NEW-PAGE is jus a standalone command with which the line count cannot be associated.
    I actually have some header details that shud only appear on 1st page , n basing on the line count all works fine on 1st page ..but on the 2nd page the header details ned not appear , so only the itab details are getting printed , so the sy-tabix value remains the same but the line count is less than the 1st page leaving some space at the bottom of the page .
    And in the subsequent pages the printing takes place but from the begining of the page n also leaving more space at the bottom of the page.
    I want that equal no of lines get printed each page , also leaving equal no of lines at the bottom of each page.
    Hope I'm  sounding clear.
    Any answers ?
    Thanks.
    Sangeet.

  • Regarding line count in normal list

    Hi all,
    In normal list am giving line count as 32. Its showing output correctly in my system. But when am seeing my output in other system the second page header is coming in the first page. I think according to configuration line count may change. Plese tell what i need to do to get ouput correct irrespective of system(Is there any system variable is there to do this).

    This actuly configuration problem
    configuration of sap in that system not done properly'
    I am sying this becouse i also faced same problem
    so configer it again ....
    Waiting for reward points........................

  • Dynamic setting of line count and footer in classical report

    Hi all,
    In classical report,we can set line count and footer at the beginning of the report  as Line-count 6(2), here out of 6 lines 4 lines is for content and 2 lines is for footer (assume no standard heading), but if my report produces less content than 4 say 3 at run time ,then footer will not be displayed .Here again i have to set line count and footer as 5(2) in order to get the footer to be displayed ,so How can i achieve dynamic setting of the line count and footer,
    Thanks,
    Avinash

    Use RESERVE,
    START-OF-SELECTION.
    RESERVE 6 LINES.           "at the last of your code
    This will trigger a page-break & footer will be displayed.

  • How to allocate space for headers in reports through line size r line count

    hi ,
    may i know how to allocate space for a header ( we do the same for footer through line-count ( footer space ) ) through line size or line count in reports...
    thanks in advance..

    Hi..,
    There is no need to reserve any space for the header. TOP-OF-PAGE can by default allocates the space for the header.
    If you still having confusion just  go ahead with this link. This is the research on same thing in defferent way.
    [Link|lines reservation for TOP-OF-PAGE & END-OF-PAGE;
    Thanks,
    Naveen.I

  • Line size and line count

    Hi all,
    May i know about line size and line count impact on reports ?
    i mean depending on line sizes values i.e 200 etc hw it will effect report either in output display  or length ?
    and also ablout line count too.
    Thanks in advance.

    This information may help you
    *... LINE-SIZE width *
    Effect
    This addition specifies the line width of the basic list and details list of the program to width characters, and sets the system field sy-linsz to this value. The line width determines the number of characters in the line buffer as well as the number of columns in the list displayed. The value width must be a positive numeric literal. The maximum line width is 1,023 characters.
    When the LINE-SIZE is not specified, the line width of the basic list is set to a standard width based on the window width of the current Dynpro, but is at least as wide as a standard size SAP window. For the standard width, the contents of sy-linsz is 0. The LINE-SIZE overwrites the value of the like-named LINE-SIZE addition to the statement SUBMIT and can be overwritten during list creation with the like-named LINE-SIZE addition to the statement NEW-PAGE.
    Note
    The current maximum line width is stored in the constants slist_max_linesize of the type group SLIST. Also defined there is a type slist_max_listline of type c with length slist_max_linesize.
    *... LINE-COUNT page_lines[(footer_lines)] *
    Effect
    This addition specifies the page length for the basic list of the program to page_lines lines and fills the system field sy-linct with this value. If the LINE-COUNT is not specifed, and if page_lines are less than or equal to 0 or greater than 60,000, then the page length is set internally to 60,000. This setting overwrites the passed value of the like-named LINE-SIZE addition to the statement SUBMIT and can be overwritten during list creation with the like-named LINE-COUNT addition to the statement NEW-PAGE.
    If you optionally specify a number for footer_lines, a corresponding number of lines are reserved for the page footer, which can be described in the event block END-OF-PAGE.
    You must specify page_lines and footer_lines as numeric literals.
    Notes
    For screen lists, you should use the standard value since, as a rule, page breaks defaulted through LINE-COUNT are not adjusted to the window size.
    You should also use the standard value for print lists, so that you can still select the page size on a printer-specific basis. A print list should be created in such a way so that it can handle every page size.
    Specifying a fixed line count is only useful for form-type lists with a fixed page layout. Here, however, you should always check whether such forms can be created by other means, such as SAPScript forms.

  • Director 11 line.count problem?

    Hi all. My name is Natassa and this is my first time here!
    I am not new with Director, but can't figure out the
    following!
    There seems to be something wrong when working with text
    members regarding the line.count property. In our project, i parse
    through XML files and store data in text members which are placed
    on stage and run a mouseOver script using pointToLine(the mouseLoc)
    in order to change the color of the "active" line of the text
    member.
    The XML files are all utf-8 encoded, since we have english,
    greek and french text.
    I use a repeat loop so as to fill a text member with some
    titles.
    I have tried everything i could think of and could not solve
    my problem. So, i thought i should try something very basic and
    figure out what is going on.
    Nothing seems to be working!
    I have run the following basic scripts with the following
    output:
    Example A
    script:
    --I use numToChar(940) which is a greek character, since in
    our project we have english, greek, french all utf-8 encoded
    member("myText").text=""
    repeat with i=1 to 300
    myString = " line " & numToChar(940) &
    numToChar(940) & numToChar(940) & numToChar(940) & i
    member("myText").line[ i ] =myString
    put i,member("myText").line[ i ],
    member("myText").line.count
    end repeat
    Message window output:
    -- 1 " line άάάά1" 1
    -- 2 " line άάάά2" 2
    . (everything ok so far)
    -- 232 " line άάάά232" 232
    -- 233 " line άάάά233" 233
    -- 234 " line άάάά234" 208
    -- 235 "" 235 HERE IS THE PROBLEM - NO STING STORED IN THE
    TEXT MEMBER AFTER THIS LINE
    -- 236 "" 236
    -- 237 "" 237
    -- 299 "" 299
    -- 300 "" 300
    put member("myText").line.count
    -- 300
    put member("myText").line[300]
    Example B
    script:
    --I use numToChar(940) which is a greek character, since in
    our project we have english, greek, french all utf-8 encoded
    member("myText").text=""
    repeat with i=1 to 300
    myString = " line " & numToChar(940) &
    numToChar(940) & numToChar(940) & numToChar(940) & i
    member("myText").setContentsAfter(RETURN & myString)
    put i,member("myText").line[ i ],
    member("myText").line.count
    end repeat
    Message window output:
    -- 1 " line άάάά1" 2
    -- 2 " line άάάά2" 3
    . (everything ok so far)
    -- 232 " line άάάά232" 233
    -- 233 " line άάάά233" 234
    -- 234 " line άάάά234" 209 HERE IS THE
    PROBLEM - line.count DOES NOT WORK CORRECTLY
    -- 235 " line άάάά235" 210
    -- 299 " line άάάά299" 274
    -- 300 " line άάάά300" 275
    put member("clippings").line.count
    -- 275
    -- But if i copy the text of the member and paste it into a
    text editor, there are 300 lines!!!
    put member("clippings").line[300]
    -- " line άάάά300"
    As a result, the pointToLine(the mouse Loc) is not working
    well! The mouse is over a line and a different line has the
    "active" color...
    As you can see, the problem occurs after line 234!! :-|
    Does anyone else have the same problem? I have a deadline and
    can't figure out what to do!!
    p.s. I updated a director MX file to a director 11 file. A
    text member (contains greek and latin characters) opened in MX has
    a line.count of 384 (correct) and the same member opened in 11 gave
    a line.count of 275!!!!! Again the same problem with
    pointToLine()...

    >
    Example A
    >
    > -- 233 " line ????233" 233
    > -- 234 " line ????234" 208
    > -- 235 "" 235 HERE IS THE PROBLEM - NO STING STORED IN
    THE TEXT MEMBER
    > AFTER THIS LINE
    FWIW: I can replicate this problem, and it doesn't occur in
    DMX2004, so
    it's a new bug. It seems that line 234 gets the line number
    wrong (208)
    and it all turns to custard after that
    >
    Example B
    >
    > -- 232 " line ????232" 233
    > -- 233 " line ????233" 234
    > -- 234 " line ????234" 209 HERE IS THE PROBLEM -
    line.count DOES NOT WORK
    > CORRECTLY
    > -- 235 " line ????235" 210
    And I can replicate this too.
    However, I can "fix" your second example by referencing
    member.text.line
    instead of member.line. See the following alteration to your
    original
    handler:
    on test2
    member("myText").text=""
    c = numToChar(940)
    s = "line " & c & c & c & c
    repeat with i=1 to 300
    member("myText").setContentsAfter(RETURN & s & i)
    put i, member("myText").text.line
    , member("myText").text.line.count
    end repeat
    end
    I can't find a fix for your first example in a similar
    fashion. It's not
    permitted to execute member("myText").text.line =
    "string"
    > As a result, the pointToLine(the mouse Loc) is not
    working well! The mouse is
    > over a line and a different line has the "active"
    color...
    > p.s. I updated a director MX file to a director 11 file.
    A text member
    > (contains greek and latin characters) opened in MX has a
    line.count of 384
    > (correct) and the same member opened in 11 gave a
    line.count of 275!!!!! Again
    > the same problem with pointToLine()...
    Try instead measuring member.text.line.count instead of
    member.line.count
    I will try to replicate the pointToLine() issue and see if I
    can find a
    workaround.

  • How to get file line count.

    Hey guys,
    How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
    Is there any other methods?
    Thanks in advace!

    What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
    Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
    you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
    InfoFetcher.java
    ============
    package tjacobs.io;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    * InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
    * InfoFetcher can be set up with a thread so that it reads from an input stream
    * and report to registered listeners as it gets
    * more information. This vastly simplifies the process of always re-writing
    * the same code for reading from an input stream.
    * <p>
    * I use this all over
         public class InfoFetcher implements Runnable {
              public byte[] buf;
              public InputStream in;
              public int waitTime;
              private ArrayList mListeners;
              public int got = 0;
              protected boolean mClearBufferFlag = false;
              public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
                   this.buf = buf;
                   this.in = in;
                   this.waitTime = waitTime;
              public void addInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        mListeners = new ArrayList(2);
                   if (!mListeners.contains(fll)) {
                        mListeners.add(fll);
              public void removeInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        return;
                   mListeners.remove(fll);
              public byte[] readCompletely() {
                   run();
                   return buf;
              public int got() {
                   return got;
              public void run() {
                   if (waitTime > 0) {
                        TimeOut to = new TimeOut(waitTime);
                        Thread t = new Thread(to);
                        t.start();
                   int b;
                   try {
                        while ((b = in.read()) != -1) {
                             if (got + 1 > buf.length) {
                                  buf = IOUtils.expandBuf(buf);
                             int start = got;
                             buf[got++] = (byte) b;
                             int available = in.available();
                             //System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
                             if (got + available > buf.length) {
                                  buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
                             got += in.read(buf, got, available);
                             signalListeners(false, start);
                             if (mClearBufferFlag) {
                                  mClearBufferFlag = false;
                                  got = 0;
                   } catch (IOException iox) {
                        throw new PartialReadException(got, buf.length);
                   } finally {
                        buf = IOUtils.trimBuf(buf, got);
                        signalListeners(true);
              private void setClearBufferFlag(boolean status) {
                   mClearBufferFlag = status;
              public void clearBuffer() {
                   setClearBufferFlag(true);
              private void signalListeners(boolean over) {
                   signalListeners (over, 0);
              private void signalListeners(boolean over, int start) {
                   if (mListeners != null) {
                        Iterator i = mListeners.iterator();
                        InputStreamEvent ev = new InputStreamEvent(got, buf, start);
                        //System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
                        while (i.hasNext()) {
                             InputStreamListener fll = (InputStreamListener) i.next();
                             if (over) {
                                  fll.gotAll(ev);
                             } else {
                                  fll.gotMore(ev);
    InputStreamListener.java
    ====================
    package tjacobs.io;
         public interface InputStreamListener {
               * the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
              public void gotMore(InputStreamEvent ev);
               * reading has finished. The entire contents read from the stream in
               * in the buffer
              public void gotAll(InputStreamEvent ev);
    InputStreamEvent
    ===============
    package tjacobs.io;
    * The InputStreamEvent fired from the InfoFetcher
    * the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
    public class InputStreamEvent {
         public int totalBytesRetrieved;
         public int start;
         public byte buffer[];
         public InputStreamEvent (int bytes, byte buf[]) {
              this(bytes, buf, 0);
         public InputStreamEvent (int bytes, byte buf[], int start) {
              totalBytesRetrieved = bytes;
              buffer = buf;
              this.start = start;
         public int getBytesRetrieved() {
              return totalBytesRetrieved;
         public int getStart() {
              return start;
         public byte[] getBytes() {
              return buffer;
    ParialReadException
    =================
    package tjacobs.io;
    public class PartialReadException extends RuntimeException {
         public PartialReadException(int got, int total) {
              super("Got " + got + " of " + total + " bytes");
    }

  • Dynamic line counter works but changes to all ones when saved.

    I am using
    this.rawValue = this.parent.parent.index + 1;
    to make a line counter and it seemed to have worked in past but through some changes I guess something broke. Now it works at first but when you save and re-opens, all lines are labeled as 1. Any one have any idea what this could be?

    I'm not sure why startMovie() is not firing. I have not encountered that issue before.
    Here is a workaround that might ensure that a #startMovie event is sent.
    Create a timeout object with a period of 0 and an object as its target. Since the timeout will never be triggered when the period is 0, the name of the timeout handler is unimportant
    Set the persistence of the timeout to TRUE
    All system events in Movie Scripts will now be called twice.
    You can create an empty movie and give it this Movie Script, to test:
    global gWrapper
    on enterFrame()
      if not gWrapper then
        gWrapper = script(1).create()
      end if
    end
    on startMovie(instance, timeOut)
      put instance, timeOut
    end
    on mouseUp()
      go movie the movie
    end
    on exitFrame()
      go the frame
    end
    -- TIMEOUT WRAPPER --
    on create(me)
      vTimeOut = timeOut().new("SystemEvents", 0, #nullHandler, me)
      vTimeOut.persistent = TRUE
      return true
    end create

  • Line-size line-count.

    Hi frnds,
       I need to change the values of line-size and line-count dynamically. If option 1 is selected, then the line size should be 132 and line count 60 . if option 2 is selected then line size should be 60 and line count 90.
       How can i do. Please help me.
       Thanks in advance

    Hi pankaj ,
       Thanks for ur reply. It works fine.
    But in report statement i had
        Line-count 60(3).
    How can i specify here. I can use new-page line-count 90.
    But if i specify new-page line-count 90(3). It throughs an error.
    How can i specify 3 value in newpage statement.
    Please clarify my doubt. Whether the (3) value changes while specifying new-page or only 60 changes to 90 and (3) still remains for 90 line-count too.
    Thanks in advance

  • Add line count

    Hi,
    I'm trying to get the kerning character's report from our document. I have done the script without the line count, can you please guide to me "how to add the line count with in this script".
    //~ Define variables
    var myDoc = app.activeDocument;
    var myDocPath = myDoc.filePath;
    var myDocName = myDoc.name;
    Fnd = new Array();
    FoundContents = new Array();
    totalArray = new Array();
    try
        var myColor = app.activeDocument.colors.item("KER").name;
    catch(myError)
        var myColor = app.activeDocument.colors.add();
        myColor.name = "URL";
        myColor. model = ColorModel.process;
        myColor.colorValue = [15, 100, 100, 0];
    //~ End define variables
    //Array start for find urls and apply color
    var doc = app.activeDocument,
        _stories = doc.stories;
    for(var i=0;i<_stories.length;i++)
            var characters = _stories[i].characters;
            for(var j=0;j<characters.length;j++)
                    if(characters[j].insertionPoints[-1].kerningMethod != "Metrics" && characters[j].insertionPoints[-1].kerningMethod != "Optical")
                            if(characters[j].insertionPoints[-1].kerningValue <= -51)
                                    characters[j+1].fillColor = myColor;
                                    characters[j].fillColor = myColor;
    reportPage = new Array();
    reportContents = new Array();
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.fillColor = myColor;
    var myFoundColor = app.activeDocument.findText();
    for(f=0; f<myFoundColor.length; f++)
        var myFoundPage =  myFoundColor[f].parentTextFrames[0].parentPage.name;
         Fnd.push(myFoundPage)
        var myFoundContents = myFoundColor[f].contents;
        FoundContents.push(myFoundPage + "\t" + myFoundContents + "\r")

    Try this,
    //~ Define variables
    var myDoc = app.activeDocument;
    var myDocPath = myDoc.filePath;
    var myDocName = myDoc.name;
    var result = [];
    try
        var myColor = app.activeDocument.colors.item("KER").name;
    catch(myError)
        var myColor = app.activeDocument.colors.add();
        myColor.name = "URL";
        myColor. model = ColorModel.process;
        myColor.colorValue = [15, 100, 100, 0];
    //~ End define variables
    //Array start for find urls and apply color
    var doc = app.activeDocument,
        _stories = doc.stories;
    for(var i=0;i<_stories.length;i++)
            var characters = _stories[i].characters;
            for(var j=0;j<characters.length;j++)
                    if(characters[j].insertionPoints[-1].kerningMethod != "Metrics" && characters[j].insertionPoints[-1].kerningMethod != "Optical")
                            if(characters[j].insertionPoints[-1].kerningValue <= -51)
                                    characters[j+1].fillColor = myColor;
                                    characters[j].fillColor = myColor;
                                    result.push(characters[j].parentTextFrames[0].parentPage.name + "\t" + characters[j].parentStory.characters.itemByRange(characters[j].parentTextFrames[0].lines[0].index,  characters[j].index).lines.length + "\t"+ characters[j].contents + "\r")
    alert(result)
    Regards,
    Chinna

  • How to get logical JTextArea line count

    Hi,
    I would like to get the logical JTextArea line count. The existing
    getLineCount method returns the line count based on "\n", which
    is not what I want.
    Any ideas?
    Thanks,
    Pin

    I found the following solution in the forum and it works.
    I haven't tested for all cases though...
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    Thanks,
    Pin

Maybe you are looking for