Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:37:45+00:00 2026-06-15T19:37:45+00:00

I’ll preface this by stating that I know Java is not JavaScript and vice

  • 0

I’ll preface this by stating that I know Java is not JavaScript and vice versa.

I’ve got a project where I need to count occurrences of words for each of 1750 document names and document contents. I’ve got some awesome JavaScript from a colleague that does exactly what I want from a form input on a web page.

I want to use Java’s FileReader, BufferedReader, walkFileTree, etc. to traverse the directories in which the documents live.

I’m not sure if this is the most efficient or effective approach, but both the Java and JavaScript parts of the code are working independently of one another now, and I’d like to see if I can get them to pass data between them before I start re-inventing the wheel.

Here’s where I am so far. I’m stuck at the CLParse method & have inserted pseudocode:

public static void main(String... aArgs) throws FileNotFoundException    {
    File startingDirectory= new File("CGT");
    List<File> files = FileListing.getFileListingNoSort(startingDirectory);
    for(File file : files )           {
        CLParse(file.toString());
    }   }

static private List<File> getFileListingNoSort(File aDirectory) throws FileNotFoundException    {
    List<File> result = new ArrayList<File>();
    File[] filesAndDirs = aDirectory.listFiles();
    List<File> filesDirs = Arrays.asList(filesAndDirs);
    for(File file : filesDirs)          {
        result.add(file); //always add, even if directory
        if ( ! file.isFile() )   {
            List<File> deeperList = getFileListingNoSort(file);
            result.addAll(deeperList);
        }      }      
    return result;
    }

 /* is something like this doable and how would I do it?
 */
public static void CLParse(String fn) {
      pass fn to JavaScript counter
      return an array of {word,occurences} for the string
      write array to file
      }

I’ll be creating another set of methods to extract and pass the document CONTENTS as a string as well. I’d love to know if anyone has any practical experience passing values back and forth between Java and JavaScript, and advice on a good/better way to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:37:47+00:00Added an answer on June 15, 2026 at 7:37 pm

    You got 2 Options to let them interact with each other, which i know:

    1.Applet <-> javascript

    2.Serlvet <-> javascript

    With option 1, you have to build a Communication with a JSObject: JSObject

    or you cann call the Applets Method instanstly with document.appletname.methodname();
    with this you can even Parse same simply Formats to each other.

    With Option 2 you have to build a communication with a Servlet.

    in here you have to send an Ajax request to the the Servlet:

    $.post('login',{name:"Peter", pw:"123456"},function() 
    { 
       //do whatever
    })
    

    JavaServlet class

    the first comment, has to written as an Servlet in your web.xml, it´s the servlet pattern.
    the second ones, are the parameters which can be read in the servlet. the function describes the stuff, which can be done in the request.

    The differences between these two Options are:

    1.the Applets runs on the users Computer, so you can access his files. But for this your applet has to be signed.

    2.the Servlet runs on the Server. Here you have got full file access(if the system allows you too have it).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
Does anyone know how can I replace this 2 symbol below from the string
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have thousands of HTML files to process using Groovy/Java and I need to
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.