On Wed, 19 Mar 2003 07:30:20 +1000, Brad Wright wrote about "Re: [PHP]
Using PHP to get a word count of a MSword doc" what the universal
translator turned into this:

>Thanks for the reply Rene,
>
>Any change of a code sample of how u did this?? Im not at all experienced in
>Java.
>
>Thanks again for replying

Weren't sure whether or not to post this to the list or not, since Java
ain't really got anything to do with PHP ... but I did it anyway...

Anyways, had to dig a little, as I did this for a school project ...

Here's the Java function as it looks in the project, just snipped it all
to make it clearer to see the connection:

// function countWords
  public void countWords(String tekst) {
    String tmpString;
    st = new StringTokenizer(tekst);
    numChars = 0;
    numWords = st.countTokens();
    numWordsOver6 = 0;
    while (st.hasMoreTokens()) {
      tmpString = st.nextToken();
      if (tmpString.length() > 6) {
        numWordsOver6++;
      } // if
      numChars += tmpString.length();
    } // while
    percWords = (double) (numWordsOver6 / numWords) * 100;
  } // method countWords

As I said, not easily convertible to PHP since Java is purely object
oriented, and PHP is not really so ...

>From the code above:

st = new StringTokenizer(tekst);
/* Create new tokenizer object, and send it string tekst */

numWords = st.countTokens();
/* Count number of tokens in the text. This is a standard function in the
Java StringTokenizer class. */

The rest is more or less self-explanatory. Java buils heavily on C++,
which shows ...

I'm not gonna go further into Java than this. I don't use it myself, but
in some ways it's alot simpler than other languages to work with. But when
it comes to I/O functions, Java is a nightmare. Loading a file into Java
is by no means an easy task, and requires careful studying of how the
system calls needs to made ...

Totally don't understand why anyone likes to use a language designed for
washing machines and coffee makers...(that's actually part of why it's
called Java)

Rene

-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to