File i/o qs with html

hey everybody,
these java forums are a valuable resource so i decided to ask a question about a problem i have been having with my code.
i am trying to read in a file (it's a txt file but with all html code in it)...simple reading is not a problem, but i am trying to filter out the tags and HTML special characters (& ; ,etc)...
eventually i will want to store the "nice" words in an array or something.
here is what i have so far but i cannot seem to figure out what to change? the delimeter setting in the string buffer..or? i've tried a lot of stuff and stripped it back down to how it was at first.
import java.util.*;
import java.io.*;
public class LexicalAnalysis
     public static void main(String args[])
          new LexicalAnalysis();
     StringBuffer dest = new StringBuffer(" ");  // Temporary storage
     private String tag;
     public LexicalAnalysis()
        try
            BufferedReader br = new BufferedReader(new FileReader("cs214sp02.txt"));    // Open source doc   
            String line = null;
            StringBuffer source = new StringBuffer();
            while((line = br.readLine()) != null)   // Read document to StringBuffer
                source.append(line);
            filter(source.toString());
        catch(IOException ioe)
            ioe.printStackTrace();
        private void filter(String src_)
        StringTokenizer st = new StringTokenizer(src_, " <");  // need to decide deilmeters.          
         int tokens = st.countTokens();  // Number of tokens in document          
        for(int i=0; i<tokens; i++) // go through all tokens
            String token = st.nextToken();                                
               System.out.print(token+" "+"\n");
        save(dest.toString());  // Save to disk  */ 
    private void save(String dest_)
        try
            String fileName = "C:/Windows/Desktop/TEST.txt";
            PrintWriter pw = new PrintWriter(new FileWriter(fileName));
            pw.println(dest_);   
            pw.flush();
            System.out.println("\n\n\nend doc!");       
        catch(IOException ioe)
            ioe.printStackTrace();

hey everybody,
i switched up the code - i now read line by line from the file.. i also used a tokenizer in a different fashion.. it seems to work nicely except one problem which i hope someone can help me with!
when i print out the tokens to the screen.. for some reason, the last word in the html file that it reads is printed multiple times! i have no idea why!
maybe ill make this a new post on the forum as well for new people to take a look too :)
import java.util.*;
import java.io.*;
public class LexicalAnalysis
     public static void main(String args[])
          new LexicalAnalysis();
     StringBuffer dest = new StringBuffer(" ");  // Temporary storage
     private String tag;
     public LexicalAnalysis()
        try
            BufferedReader br = new BufferedReader(new FileReader("cs430fa02.txt"));    // Open source doc   
            String line = null;
            while((line = br.readLine()) != null)   // Read document to StringBuffer
                filter(line);
        catch(IOException ioe)
            ioe.printStackTrace();
     private void filter(String src_)
          StringTokenizer st = new StringTokenizer(src_, " <>;&#.", true); //StringTokenizer(src_, " "); // need to decide deilmeters.       
          int tokens = st.countTokens();        // Number of tokens in document       
          String token="";     
          for(int i=0; i<tokens; i++)
               if(st.hasMoreTokens())
                    token = st.nextToken();
               if(token.equals("<"))
                    while(!token.equals(">"))
                         token = st.nextToken();
               if(token.equals("&"))
                    while(!token.equals(";"))
                         token=st.nextToken();
               if(!token.equals(">") && (!token.equals(";")))// && (!token.equals("."))))
                    System.out.print(token.trim()+" ");
               //save(dest.toString());        // Save to disk  */   
    private void save(String dest_)
        try
            String fileName = "C:/Windows/Desktop/TEST.txt";
            PrintWriter pw = new PrintWriter(new FileWriter(fileName));
            pw.println(dest_);   
            pw.flush();
            System.out.println("\n\n\nend doc!");       
        catch(IOException ioe)
            ioe.printStackTrace();

Similar Messages

  • I have a number of pages with html extension in different files. Is it possible to merge them into one file? Is it possible to convert them into another file type such as PDF, MOBI, or EPUB? Thanks

    While downloading an eBook from internet, I found a book in a folder containing around 123 files, which is equivalent to the number of pages of the book.
    My interest is to bring them together in one file so that I can read it at a time. As the interface is not comfortable with html, I also like to convert it into another more suitable file format.

    Hello djensen1x,
    Could you please let me know what version of Acrobat are you using.
    Also, tell me your workflow of combining those PDF files?
    Please share the screenshot of the error message that you get.
    Hope to get your response.
    Regards,
    Anubha

  • How to insert a shoutbox and a counter in a flash file with html code?

    How to insert a shoutbox and a counter in a flash file with
    html code?
    Code shout box
    <!-- BEGIN MYSHOUTBOX.COM CODE -->
    <iframe src="
    http://489676.myshoutbox.com/"
    width="152" height="300" frameborder="0"
    allowTransparency="true"></iframe>
    <!-- END MYSHOUTBOX.COM CODE-->
    Code compteur
    <script type="text/javascript" src="
    http://www.123compteur.com/counterskinable01.php?votre_id=268303"></script><noscript><a
    href="
    http://www.123compteur.com"
    target="_blank">compteur</a></noscript>

    thx =D

  • Display jsp files with .html extension

    my problem is very straight forward i want all my jsp pages to be shown with .html extension. like if i have a page test.jsp and I access it through a hyperlink Test then in the browser's address bar i want it test.html .. any ideas ..

    That's is one odd request. The source for the page still shows that they're loading a .jsp file. To do what you want, you'd have to write javascript for every such link that handled that type of request.
    However, if you actually want all files with .html extensions to be processed like jsps you can:
    1. you can remap the JSP servlet in your web.xml file to another extension (though i'm not sure if thats part of the spec)
    2. you can also use the <jsp-property-group> element in web.xml to specify other files as JSPs. (thats definitely in the spec)

  • Can I upload a php file to my host with an embedded html contact form in Muse for it to work?

    Can I upload a php file to my host with an embedded html contact form in Muse for it to work?

    That would require to know your hosting provider and his requirements. And therein also lies the answer: You cannot blindly design a form in Muse and just hope it will work, you have to know this stuff beforehand and design "to spec".
    Mylenium

  • Can not use scroll mouse in html tab when open pdf file in new tab with middle button but will avaliable only after switch to pdf tab and switch back to html

    When I open a "pdf" file in new tab with middle mouse click. After few second my mouse will not able to scroll in page that I read. But it will be able to scroll only after I click to any opened pdf tab and click on pdf document and click back on previous tab to continue reading. It is not only happen on my laptop also on my desktop too. (winxp 4gb/8gb ram core2 duo 2.66)

    There's a Bug filed about that issue.

  • URL iview with HTML file located in Portal server.

    I created URL iview pointing to HTML file located in the Portal server. When I try preview it is not working. We wanted to use this iview to create space between two iviews.
    This is going to be blank iview.
    I saved the HTML file same as where index.html file of webas is located.
    Please let me know what is missing here. What kind of path I need to give in the URL of the iview.

    Hi Nagesh,
    Are you saying that you created a HTML file on the file system of the portal server or did you create the HTML file within a KM repository on the portal?
    If it is the 1st option you should have the HTML file hosted under a webserver such as IIS or Apache and then use the URL that the website is created under.
    If it is a file within KM then open the properties of the HTML document that you have created and use the Access Link value as the URL for the iView.
    Please let me know if you need further clarification.
    Regards
    Daniel

  • Deploying Servlet with HTML file on Tomcat

    Hi ,
    I created a servlet and an html file. The html file accepts user data and passes it to servlet.
    I want to deploy these two files using Tomcat server. Please tell me a sure procedure for deploying both files.
    Regards,
    ap.

    First of all its better to make a jsp rather than one HTML and a servlet but anyhow in order to deploy it first build your project and create a war file which should contain your HTML and servlet and the web.xml.
    Then place this war file inside the webapps folder of tomcat.Start the tomcat and hit your HTML on the browser....

  • Elements do not show up in edge file but they do in HTML file; no errors occured

    I am a senior in college working on building a website for a fictional company for a year-long thesis graphic design project. In my class last semester, I learned how to use Edge Animate and created an 11 page website without any trouble. I had always kept the files saved to my flash drive, and kept a backup on my personal laptop as well as on my external hard drive. There was also a backup of the files on a disc that I turned into my professor in mid-December. All of these files worked fine at the time.
    In early January, I wanted to make changes to the website so I installed a trial version of Edge Animate on my laptop. When I opened any of the edge files from any of the backups, the stage was blank and the animations did not show up on the timeline. The elements of the website still show up in the Library but they are no longer arranged on the stage. When I got back to school at the end of January, I tried opening the files on the school computers and had the same problem. I asked my professor to try the file that was saved to the disc and he encountered the same issues on his computer. All of these computers are either iMacs or Macbook Pros.
    I have not recieved any error messages and did not do anything to corrupt the files or save over them. I am able to open the html files in a browser with no issues; all animations and images work fine. The only change I can think of is that Edge may have been updated over break and when I installed the trial version I installed a newer version, and for some reason the new version of the program could not properly load my project that I started on a older version in October or November of 2013.
    I am happy to upload the files but I am unsure how to do that. Please let me know if there is a way to resolve this issue, or will I have to start over?
    Thank you!

    Try to clear your preference and restart your Animate.See if that fixes your problem
    http://helpx.adobe.com/edge-animate/kb/restore-preferences-edge-animate.html
    If  that does not work see if there is a lloopback address lookup.
    Check out the correct answer in this post to fix that http://forums.adobe.com/message/6116991
    Let us know if this fixed your issue

  • Load SWF file in main SWF with parameters

    Hello everybody,
    I recently got a new flash Application which is a Photo Gallery.
    This App is made of multiple folders (source files), a FLA file, a SWF with its javascript SWFObject and an Html page which instantiate this App with some parameters (size, config file path, ...).
    It needs an XML file to find all the Photos it displays, to do it I need to configure my application in the HTML Page and give it the "xml_path" :
    var so = new SWFObject("index.swf", "gallery", "249", "249", "10", "#111111");
    so.addVariable("xml_path","load/config.xml"); // this line is adding the path to the xml file make sure that it's name is xml_path
    so.addParam("allowfullscreen","true"); 
    so.write("flashcontent");
    By the way, I have a second application, the WebSite, which have to display the Gallery SWF in its "Gallery" page.
    Here is how I do it at the moment (in ActionScript3) :
    var swfRequest:URLRequest = new URLRequest("C:/......../Galerie/index.swf");
    var swfLoader:Loader = new Loader();
    //Charge le SWF Galerie dans le SWF Site
    swfLoader.load(swfRequest, context);
    container1.addChild(swfLoader);
    //Positionne le SWF
    swfLoader.x=10;
    swfLoader.y=120;
    It successfully loads the Gallery application but It shows an error telling me it doesn't find the XML configuration file... In the HTML file I simply had to write the "so.addVariable("xml_path","load/config.xml");" to tell where the XML file is...
    So, my question is : How can I integrate my SWF application giving it some parameters like above, in Action Script 3?
    Thank you ,
    Patrick

    No, nothing with HTML.
    I have 2 SWF applications. One is the Gallery, and the second is my Main Page.
    My Main Page must integrate the Gallery module in one of its page.
    The problem is when I try to integrate it, I think I must give de future loaded SWF some parameters like this :
    (My Main SWF loading in HTML)
    var so = new SWFObject("WebSite.swf", "flashcontent", "520", "700", "10", "#111111");
    so.addParam("allowfullscreen","true");
    so.addParam("allowScriptAccess","always");
    so.addParam("menu","false");
    so.addParam("wmode","opaque");
    so.addParam("bgcolor","#000000");
    so.setAttribute("id","flash");
    so.write("flashcontent");
    It was for the Main App. For my Gallery SWF I had to load it like this (in HTML) :
    var so = new SWFObject("Gallerie.swf", "gallery", "249", "249", "10", "#111111");
    so.addVariable("xml_path","Galerie/config.xml"); // this line is adding the path to the xml file make sure that it's name is xml_path
    so.addParam("allowfullscreen","true"); 
    so.write("flashcontent");
    So at the beginning I had 2 different projects with an HTML page for each.
    Now I wan't to directly integrate the Gallery SWF into the Main SWF. And as you have seen I must give it some parameters such as the "xml_path" and "allowfullscreen". This must be done in ActionScript 3 and I don't know how...
    I think I have to use FlashVars but I don't know how. As I said before, I have tried using the loaderinfo.parameters, but it is in read-only...
    Do you have an idea of how I can make it work ?

  • Textarea with HTML editor is not working

    Hi all,
    This is producing me a real headache.
    I created the simplest application in the world with one Textarea with HTML editor, and the editor control does not show the usual tool bar for fonts, color, alignment, etc. Just a ordinary textarea.
    Moreover, this was working before... I moved to another location in my work (me, not the server). Yes, I thought about the Internet Explorer, but Firefox has the same issue.
    So any idea I can try to make this work?
    I have another applications already in production with the same issue.
    Need help!!!!!!!!!
    Thanks in advance.
    Lukas.
    Application Express 2.1.0.00.39
    Oracle Database 10g Express Edition Release 10.2.0.1.0
    Internet Explorer 7.0.5730.11
    Firefox 1.5.0.11
    Windows XP Service Pack 2
    1 G Ram
    Pentium D CPU 2.80GHz

    Lukas,
    I would go and integrate FCKEDITOR (http://www.fckeditor.net/ ) into your application.
    Here are instructions on how to achieve this (sorry but only in German):
    http://www.oracle.com/global/de/community/tipps/einbinden_fckeditor/index.html
    It basically means:
    1) copying the files from fckeditor under the /images directory
    (you can use the instructions here: http://daust.blogspot.com/2006/03/where-are-images-of-application.html)
    2) creating two shortcuts INCLUDE_EDITOR_SCRIPTS and EDITOR
    3) placing the shortcut INCLUDE_EDITOR_SCRIPTS into the page html header and
    4) placing the shortcut EDITOR into the post element text of your plain textarea element
    That's it.
    BTW, FCKEDITOR has been included in Apex 3.0 as a standard item type.
    Regards,
    ~Dietmar.

  • How to Rename a Topic ID in Map File to Avoid Conflict with Another Program?

    Robo 8 HTML:
    Can somebody assist me in understanding how to rename a topic ID in my map.h file?
    An application programmer informs me there are nine topic IDs (shown below) in my project map file which conflict with predefined names of constants/functions from the Visual Studio Libs program and, is requesting I change the names of the topics listed below to resolve topic ID conflict in order to enable F1 call for these topics.
    #define Open    59
    #define Save    60
    #define Print   63
    #define Cut     72
    #define Copy    73
    #define Paste   74
    #define Clear   75
    #define Status  81
    #define Substructure  139
    Can I simply alter the topic names and retain their associated map numbers in <Create/Edit Map ID> dialog to resolve the map file conflict with Visual Studio Libs program functions? Or, is there more work involved in changing a topic name in a map.h file?
    Any assistance with this question is greatly appreciated.
    Thanks,
    robert

    Hi,
    Simply renaming the TopicID's in the .h file won't work. The TopicID is used in the alias file (projectname.ali) to link a map number with a topic. Also, you can use either TopicID's or map numbers to call the help. (Using TopicID's only works for WebHelp afaik.)
    If you use map numbers to call the help, you can rename the TopicID using the mentioned dialog. No problem.
    If you want to change the ID from the files, you have to change both the .h file as the .ali file. No changes to topics needed.

  • How can i turn a photoshop file into a website with knowing code? can i upload Muse or DreamWeaver?

    How can i turn a photoshop file into a website with knowing code? can i upload Muse or DreamWeaver?
    I created a few images (pages for a site) on photoshop and want to turn them into HTML code for a website- Can i Just upload the file into one of these programs and make a file with the correct code imediatly?
    I was reading about using EDGE Reform but i did not understand if i can create the code with it, in the end it says it still needs to be sent to website developer after?

    You need to look at Dreamweaver as a code editor. You need to learn to create good, clean HTML code with style sheets to make websites with Dreamweaver.
    There are tutorials that will take you from a layered .PSD file to HTML. Here's a good one:
    http://net.tutsplus.com/tutorials/site-builds/from-psd-to-html-building-a-set-of-website-d esigns-step-by-step/
    Adobe's Muse is a semi-WYSIWYG website layout creator for small websites (1-5 pages). But there is no way you can go from a .PDS file to Muse, you have to start the site in Muse.
    I have seen a few Muse sites and they're OK, but there is some code that Muse creates that is kind of odd. If you want a good, clean website that will work for you or your business, Dreamweaver is the best choice. Alternatively, you could hire a pro.
    -Mark

  • How do I resolve: "Could not complete the Crop command because the file is not compatible with this version of Photoshop" error message?

    Photoshop document created in current version of PSCC2014, now will not crop, resize, etc without throwing compatibility error.
    "Could not complete the Crop command because the file is not compatible with this version of Photoshop."
    How do I resolve without recreating the file?

    Ooops.  Hit save reply prematurely. 
    You may be able to open the flattened composite or the embedded JPEG preview of your file in Adobe Illustrator, GraphicConverter (Mac only) or some such application, but your layers will be gone.
    The problem of working across a network is that it's not supported by Adobe:
    This is the boilerplate text often used in connection to saving to a network (please NOTE the part where it explains that normally, it does work, but that it is impossible to troubleshoot someone else's network remotely, and that's why it's not supported by Adobe):
    If you are opening files over a network or saving them to a network server, please cease and desist immediately in the event you are currently experiencing problems with one or more files. Working across a network is not supported.
    See: 
    http://kb2.adobe.com/cps/406/kb406793.html
      Copy the CLOSED file from your server to your local hard disk, work on it, save it again to your local hard disk, close it, and copy the closed file back to the server.
         Of course, the fact that Adobe does not support working across a network does not necessarily mean it won't work.   It should.
        Adobe's position is that there are too many variables in a network environment for them to guarantee that everything will work correctly in every network, especially given the fact that if something does not work properly, it's probably the network's fault, and Adobe has no way of troubleshooting your network.
      If you can't work locally, you are on your own, and if something happens, you're on your own. If you must work from a server, make sure your network administrator is a competent professional.
    When problems arise, a lot of valuable work can be lost.

  • When I try to attach my css style sheet Dreamweaver gives me an error saying that my .css file appears to be an .html file and will not attach. How do I fix this so I can attach my style sheet?

    I have built a css style sheet in Dreamweaver. When I try to attach it to my html website, it prompts me that my "css file appears to be an .html file and cannot attach". I've tried removing the /* */ as suggested by other forums, but this has not resolved the issue. I was using css style sheets with no problem 2 days ago. Now I get that error message. How do I fix this so I can attach my style sheet?

    What does the code of the CSS file look like?
    An external CSS file needs to be written in CSS only (no html tags like <html>, <body>, <head>, etc ).
    It also must have a .css file extension, if yours has a .html extension it won't work.

Maybe you are looking for

  • Bit Locker on surface pro 3 ssd card

    I had a surface pro 3 which I managed to damage. There was data on the ssd that I needed so I have got it out and connected it to my laptop by usb. When I try and use open it, it comes up with bit locker drive encryption so I need a bitlocker recover

  • Issue with XML namespace and Message structure

    Hi All, I am using Oracle SOA Suite 11.1.1.4. I have SOA web service application one-way messaging wherein I keep receiving messages from the third party. The issue I am facing is with the XML namespaces which conflicts with the third party's message

  • EDI configuration for automatic IV

    Hi, What all are the steps to do EDI configuration for automatic IV in an intercompany scenario. In an STO scenario I want the invoice to generated automatically in the receiving company based on the issuing company's invoice. regards Magi

  • Have iCloud account, have changed e-mail address, can't edit iCloud account, how is this done?

    How do I edit my iCloud account?

  • CAN wrtie frequently causes the message to stop

    I am having a problem with CAN. I have a PXI RT Controller with 2 CAN cards. I am trying to send out 1 message at 50Hz and another two messages that are single writes each time through a timed loop. My problem is that when I try to change the 50 Hz m