Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Word count in IBM's RAD

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While editing a JAVA class in IBM's Eclipse, I have need of a word count feature, but don't see it. This would save me a lot of time in desk checking the validity of the many tables the class has.

Thanks, Bob
 
Saloon Keeper
Posts: 7622
68
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A "word" is not a "table" and a "table" is not a "word", so firstly, you need to be much clearer with your requirements.
 
Robert Houston
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By table I mean a variable name, like Table001, etc. I did say this was beginning Java, right?
 
Carey Brown
Saloon Keeper
Posts: 7622
68
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you could write your own. You'd need a loop to loop through file names and for each file name open a Scanner object and use the Scanner's nextLine() method to read each line. You can use String.split() to separate the line into words.
You'd want to ignore keywords: if, else, while, break, return, etc.. Then sum up the array lengths for each line.
 
Robert Houston
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Carey, will do!
 
Saloon Keeper
Posts: 23055
157
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bob, long time.

I, too am confused here. You say "tables",  we think database tables. But you said Jaca classes and most Java classes I have work with only one database table at a time, or at least an interconnected net of tables.

The Unix-family operating systems come with a standard word-count utility named "wc". It can actually count words, lines and characters in a text file. But I suspect that you want something more subtle than that.

I know many evil ways to gain wisdom from text files, but maybe you could give us some sort of example as to what your input looks like?
 
Robert Houston
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Tim, No D/B involved. I called my units of info "Tables", my bad.
BTW, in ECLIPSE to get a word count while in EDIT you hilite it and enter "CTL/SHIFT/U". You'd think it would be easily found under "EDIT", but no...
Found it in Stack Overflow.
 
Tim Holloway
Saloon Keeper
Posts: 23055
157
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bob. When you say "units of info", do you mean the variable declarations, or do you have something more complex in mind?

I'm afraid my copy of Eclipse doesn't honor Ctrl+Shift+U for Java files, although I dimly recall something like that from long ago.

Eclipse can be confusing because it's not a monolithic program, it's an OSGi services container and everything is build up out of OSGi plugins. Like Microsoft's vision of OLE, but worse. And those plugins dynamically affect the menus, toolbars, hotkeys and so forth based on what perspective you're in, which "editor" you're using and various other considerations. I wrote an editor plug-in once, incidentally, but it's not for the faint of heart. I mention that just to say that if you really wanted Eclipse/RAD to do any little tasks like what you seem to want, it's doable, given enough aspirin. Failing that, if it's building up a list of class members or the like, a stand-alone Java program could use the language introspection facilities to do that.

On the other hand, if you're trying to get a handle on the classes, methods, and members of a Java app, don't forget that under the Project menu in Java Perspective there's a "generate Javadoc" command that will scan the whole project and create full documentation including cross-references. It's the same thing used by Oracle and others to create their documentation websites.
 
Marshal
Posts: 71752
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure I would use Scanner#nextLine().
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic