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

  • SEARCH
  • Home
  • 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 6734853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:56:18+00:00 2026-05-26T10:56:18+00:00

I am making a HTML renderer. I have the html file being read into

  • 0

I am making a HTML renderer. I have the html file being read into a StreamTokenizer. At the moment it prints out the correct tokens, and in my html file specify my varbiles enclosed in dollars e.g

<html><p>$myVarToBeRendered$<p></html>

I get the correct tokens i.e it splits up the html body and vars by using the quoteChar(‘$’)

FileReader in = new FileReader(file); 
     BufferedReader reader = new BufferedReader(in); 
    StreamTokenizer tok;
    tok = new StreamTokenizer(reader);
    tok.resetSyntax();
    tok.wordChars(0, 255); 
    tok.quoteChar('$'); 

I get the string tokens

"<html><p>" , "myVarToBeRendered" and "<p></html>"

Though when reading through the token i obviously need to replace the myVar token which is identified as a quote. This myVar is used as a key in a HashMap holding the string values to be rendered to each variable. Is there a way of checking if a token is a quote? like:

if (tok.next - is a quote or inside my quotes)
     Then replace this var name with its related HashMap value

I have scoured the internet and can’t find any examples or similar questions to help me along!

Or any method I could use so I can identify which tokens are variables to used in the HashMap. Sorry if this doesn’t make sense, hope you understand what i’m trying to do!!

Many Thanks Sam

  • 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-05-26T10:56:19+00:00Added an answer on May 26, 2026 at 10:56 am

    May be I misunderstood the question, but you can check the presence of your tokens in a map by simply calling myMap.containsKey(myVarToBeRendered).

    On a separate note, I think using regex Pattern matching to extract substitution vars from your html seems like a better idea than using StreamTokenizer.

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

Sidebar

Related Questions

I am wondering if there is any technique out there for making HTML code
I have the following HTML (note the CSS making the background black and text
I have a lot of <a> html tags without the href attribute for making
I have been making HTML/PHP/MySQL database apps for quite a while now. I have
I am making one Html application. I have number of images in my folder.I
I am making a GWT app based off of an HTML mockup. The mockup
I've got an html page from where Im making this call periodically: function logon(id)
I'm currently making a GWT project where I display some HTML in a RichTextArea
Making my first steps with NHibernate, I'm trying to have it creating my Tables
I have a web application that utilises both the MVC Ajax calls: Html.ActionLink() rendering

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.