Trying to display a local HTML file

Hi all,
My program saves an HTML file to disc. If the user presses a button I want to display a new window that shows the HTML file. I know the file is good because I have viewed it in Internet Explorer. I have trawled the forums and got the following code. But i can't understand why its not working.
Any help would be much appreciated.
p.s. The HTML file was saved as a string so is all on one line. But IE doesn't seem to mind
Cheers
drb2k2
import javax.swing.*;
import java.awt.*;
import javax.swing.text.StyledEditorKit;
import java.awt.event.*;
import java.io.*;
public class DisplayHTML extends JFrame implements ActionListener
     Color Background = new Color(100, 135, 220);
     Color Buttons     = new Color(140, 170, 230);
     Container content;
     public DisplayHTML()
          UIManager.put("Button.select", Buttons);     
          content = getContentPane();
          content.setBackground(Background);
          BorderLayout border = new BorderLayout();
          content.setLayout(border);
          JPanel Button_Panel = new JPanel();
          BorderLayout buttons = new BorderLayout();
          Button_Panel.setLayout(buttons);
          Button_Panel.setBackground(Background);
          JButton Save = new JButton("Save");
          Save.setBackground(Buttons);
          Save.setToolTipText("Press here to save the results file in HTML format");
          Save.addActionListener(this);
          Save.setActionCommand("Save");
          Button_Panel.add(Save, BorderLayout.CENTER);
          JButton Quit = new JButton("Quit");
          Quit.setBackground(Buttons);
          Quit.setToolTipText("Press here to exit the screen and loose results");
          Quit.addActionListener(this);
          Quit.setActionCommand("Quit");
          Button_Panel.add(Quit, BorderLayout.EAST);
          content.add(Button_Panel, BorderLayout.NORTH);
          String line = "hoof";
          try
              BufferedReader reader = new BufferedReader(new FileReader("analysis.html"));
              while ((line = reader.readLine()) != null)
               System.out.println("Line is: " + line);
              reader.close();
          catch (IOException e)
               //CLEAN THIS UP
              System.out.println(e);
              System.exit(1);
          JTextPane HTML_Pane = new JTextPane();
          try
               HTML_Pane.setPage("analysis.html");
          catch(IOException f)
          {System.out.println("uff");}
          content.add(HTML_Pane, BorderLayout.CENTER);
          setVisible(true);
     public void actionPerformed(ActionEvent e)

<h1>oops</h1> forgot to tell you what the errors are:
a new window does pop up that is tiny.
When I drag it out the two buttons are there but the area below is just the blank textArea.
Not surprisingly this is caused because the IOException is called.
The command prompt screen shows "uff" so there is an error loading the file. Is there a way that I can just use the "line" variable?
Can't understand why its not loading because it loads fine for the buffered reader.
Cheers
drb2k2

Similar Messages

  • Displaying a local HTML File

    I wish to include a help file in my Java application. The easiest format for me to use is a local HTML page, resident in the same directory as my installed application - but I am having trouble displaying it using the jEditorPane. I realise this may look lazy, but could someone please put me out of my misery and tell me how to display a local HTML page ?

    if you want to use a button to show the file in a new window - try this one
    void button1_mouseClicked(MouseEvent e)
    AppletContext ac=getAppletContext();
    try {
    ac.showDocument(new URL("http://....."));
    catch(MalformedURLException x){showStatus(x.toString());}
    }

  • How to display local HTML file in web-view?

    Hello everyone,
    we have no problem with showing of remote HTML content from server in box on page in web view. But how we can show such a content when included in HTMLResources? In guide is just "Display a local HTML file in an in-app browser", which works wihout problem, but we don't want to show this HTML content in in-app viewer, it should be part of page.
    Thanks
    Martin

    Now i'm confused. In guide is this:
    To use local HTML files, click the folder icon and specify the local HTML file. The HTML file (such as index.html) should appear in a folder that includes any images or scripts used in the HTML file.
    But no info where such a local HTML file should reside. If this file is in HTMLResources, it is ignored.

  • WebView with local html file

    How can I use webview to display a local html file?

    Here is a link that will help:
    "How To Read a File From Your Application Bundle"
    http://iphoneincubator.com/blog/data-management/how-to-read-a-file-from-your-app lication-bundle
    but basically you do this:
    // urlLocation is of type (NSURL *) and
    // webView is of type (UIWebview *)
    NSString *filePath = \[\[NSBundle mainBundle\] pathForResource:@"MyFileName" ofType:@"html"\];
    urlLocation = \[NSURL fileURLWithPath:filePath\];
    \[webView loadRequest:\[NSURLRequest requestWithURL:urlLocation\]\];
    ALSO, make sure your html file is part of your project so that it's also part of the bundle.
    Hope this helps!

  • UIwebview load local html file problem

    Hi,
    load local html file into UIwebview the TD cell data can't display, as attached the "2817 MODEL" column data lost on screen:
    The local html file souce as:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en">
      <head>
        <title>IBM z196 zEnterprise 2817 Mainframe Reference - Technology News</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <meta http-equiv="Content-Style-Type" content="text/css">
        <meta name="robots" content="index,follow">
        <meta name="Author" content="Hesh Wiener">
        <meta name="Formatter" content="Heshomatic 6.2">
    <STYLE TYPE="text/css">
    <!--
    BODY
      font-family: Arial, Helvetica, sans-serif;
      font-size: 9pt;
    A:link{color:white}
    A:visited{color:yellow}
    -->
    </STYLE>
      </head>
      <body>
        <h2>
          IBM Mainframes:<br>
           IBM z196 zEnterprise 2817 Mainframe Reference
        </h2>
        <table border="1" style="border-collapse:collapse;" summary="2094 series economic specs">
          <tr>
            <th rowspan="2">
                2817  <br>
                 MODEL  
            </th>
            <th rowspan="2">
              FIRST<br>
               AVAIL
            </th>
            <th rowspan="2">EST  INIT<br>
            US PRICE  </th>
          <th rowspan="2"> EST INIT <br>
          MIN US MAINT</th>
            <th rowspan="2">
              APPROX MIPS
            </th>
            <th rowspan="2">
              SW PRICE<br>
               MSU
            </th>
            <th>
              LSPR RELATIVE PERFORMANCE
            </th>
          </tr>
          <tr>
            <th>
              MI z/OS 1.11
            </th>
          </tr>
      <tr>
        <td>2817-401</td>
        <td>3Q 10</td>
        <td>$975,000</td>
        <td>$6,280</td>
        <td>240</td>
        <td>30</td>
        <td>0.43</td>
      </tr>
      <tr>
        <td>2817-402</td>
        <td>3Q 10</td>
        <td>$1,187,000</td>
        <td>$6,729</td>
        <td>459</td>
        <td>58</td>
        <td>0.82</td>
      </tr>
      <tr>
        <td>2817-501</td>
        <td>3Q 10</td>
        <td>$1,244,000</td>
        <td>$7,524</td>
        <td>588</td>
        <td>74</td>
        <td>1.05</td>
      </tr>
      <tr>
        <td>2817-403</td>
        <td>3Q 10</td>
        <td>$1,385,000</td>
        <td>$8,346</td>
        <td>672</td>
        <td>85</td>
        <td>1.20</td>
      </tr>
      <tr>
        <td>2817-601</td>
        <td>3Q 10</td>
        <td>$1,423,000</td>
        <td>$9,434</td>
        <td>768</td>
        <td>97</td>
        <td>1.37</td>
      </tr>
      <tr>
        <td>2817-404</td>
        <td>3Q 10</td>
        <td>$1,570,000</td>
        <td>$10,665</td>
        <td>879</td>
        <td>110</td>
        <td>1.57</td>
      </tr>
      <tr>
        <td>2817-405</td>
        <td>3Q 10</td>
    </html>
    Please help. thanks
    Regards,
    HC

    add colspan into td tag and try it got same problem, I just discovered the td data is numeric it can't display, change td data to alphanumeric it workable to normal display.
    below td tag data is unworkable:
    <td>2817-401</td>
    <td>2817401</td>
    change to below is workable:
    <td>2817*401</td>
    <td>281740A</td>
    <td>2817-401A</td>

  • StageWebView for Local HTML file

    I simply cannot get this to work.  I see a lot of people offering advice on the web for how to implement it, I've been trying all day and it doesn't work with Adobe AIR 2.5 for Android Flash CS5 plug-in.
    Instead of linking to an external website:
         webView.loadURL(http://www.google.com);
    I want to use StageWebView (because of the nice scroll capability) to load a local html file.  I have tried EVERYTHING, and it doesn't work.
    I have included the file in the APK (tried as a subdirectory and eventually, to simplify testing, I just included it in the same directory so no complex path).
    I have tried what others had recommended:
        webView.loadURL("test.html");
    I have tried using the filesystem and resolving the path:
        import flash.filesystem.File; 
        var file:File = File.applicationDirectory.resolvePath("test.html") ;
        webView.loadURL(file.nativePath) ;
    I have tried numerous change-ups on the filesystem approach, including:
        var file:File = new File("app:/test.html");
    and
        webView.loadURL(file.url);
    NONE OF THESE THINGS WORK.  Can anyone help me?  I'd like to have scrollable content, included inside the Android app - like a license html file or others.
    If none of this will work, any suggestions on creating simple, scrollable content that looks nice (scroll pane, scroll list, anything?)

    Hi Joe,
    can you show code snippet for the 1st solution? With loadString you can't load anything else into that page (i..e stylesheet)
    Edit: soon after I've posted this question I have found a solution:)
    var resultsPageUrl:String = File.applicationDirectory.resolvePath("output-html/result_html_pattern.html").nativePath;
    //and later
    webView.loadURL(resultsPageUrl);
    Edit2: above was just enough to have it working in adl still no joy
    Here is an example of temporary file being loaded, this works, http://forums.adobe.com/message/3443946
    var source:File = File.applicationDirectory.resolvePath("output-html");//copy entire folder (with css)
    var destination:File = File.applicationStorageDirectory;
    source.copyTo(destination, true);//copy to the application storage
    //get path to the html page within copied folder
    var resultsPageUrl:String = "file://" + destination.resolvePath("result_html_pattern.html").nativePath;
    best regards

  • Trying to find the AICCTracking_for_director.html file

    I am trying to find the AICCTracking_for_director.html file. Can anyone
    point me in the right direction. I have already tried downloading and
    unzipping the DirectorLessonBuilderSupport.zip file on the adobe site
    but without success. It downloads fine but will not unzip.
    I do not have a director 8 disc to check, as i read it can be located on that,
    in the goodies folder. If anyone knows of anywhere i can find it,
    please let me know. Thanks

    Thanks Bartek!
    I already looked at that code but didn't get it to work. Messed something up with headers and then jumped to the wrong conclusions...
    Now it works
    Thanks again!

  • How to load local html-file into webBrowser tool? [SDK 6.5]

    The webbroser tool lets you load an external html by inputting the adress in its "Url"-property.
    But how do you load a local html-file that is added to your project? Lets say the path is: Folder1/Subfolder1/Webpage1.html. What would I put in the Url-property to make this work?
    While on this subject, what is the support for css and javascript when using locally loaded webpages in the webbrowser?

    Thanks for the answer Malleswar, but I have now played around with all variations of that code-line that I can think of, but still I can not locate the html-file that is located within the project. Since Im planning to distribute the html-files with the executable (as one file) it should read it directly from wherever the application is installed.
    The html-file is included within the project. Solution Explorer -> Solution 'myProject' -> myProject -> Webpage1.html
    Which is (as usual) also where the Form1.cs (which contains the webBrowser-component) is located.
    Any ideas of how the Uri should be constructed in this case?
    Thanks,
    Daniel

  • Opening local .html files on iPad

    I have created a personal homepage that I have loaded on my Macs at home. Any way I can use this file on my iPad 3?

    It is possible to open local HTML files in Safari on iPad2. Easy!
    Open your Safari.
    Touch Bookmark icon for a little while.
    A dialogue box appears with "/var/Mobile" title.
    Go to "Applications" > your app (iFile, GoodReade or whatever yours) > Documents.
    And you are there. Open your HTML files.
    Now you can go anywhere to and fro without problem.
    It is FTP:///.
    If need later, Bookmark that.
    With Loving-Kindness!
    bhikkhusirin

  • Parse local HTML files

    Hi,
    I want to parse local HTML files.
    Is there another way than using the Internet Explorer($ie = new-object -com "InternetExplorer.Application";) (without relaying on external packages)?
    At the moment I do something like that:
    $ie = new-object -com "InternetExplorer.Application";
    Start-Sleep -Seconds 1
    $ie.Navigate($srcFile)
    Start-Sleep -Seconds 1
    $ParsedHtml = $ie.Document
    foreach($child in $ParsedHtml.body.getElementsByTagName('table'))
    I still want to have the methods like 'getElementById()' or 'getElementByTagName()'.
    With my current approache, the performance is not realy good and it seems that the iexplorer.exe process is not terminating at the end of the script. 
    Also it seems to have sideeffects with running internet explorer instances (from GUI) - not working to start IE in powershell sometimes.
    Last time I also have a hanging script, not continuing till i manually terminate the iexplorer.exe process.
    The error was:
    Exception calling "Navigate" with "1" argument(s): "The remote procedure call f
    ailed. (Exception from HRESULT: 0x800706BE)"
    At D:\Scripts\Run.ps1:529 char:14
    + $ie.Navigate <<<< ($src)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation
    so I would prefere a method parsing HTML without IE.

    Hi John Mano,
    Please also try to Parse local HTML files with
    System.Xml.Linq, the script may be helpful for you:
    Using PowerShell to parse local HTML files  
    I hope this helps.                               
    XML?
    I thought HTML is not compatible with xml. 
    And as I don't know LINQ good ... 
    Ok, I'll give it a try. later.
    I can't answer the question about other ways to parse HTML, but to close your IE session you should do the following:
    $ie.Quit() # this terminates the IE process
    $ie = $null # this frees the COM object memory
    Thanks for that.
    I now use that, but seems to be still some IEs open ...
    Maybe a path missing where i dont do it.
    But finally I still get this error. And it is blocking the whole script ...
    Exception calling "Navigate" with "1" argument(s): "The remote procedure call f
    ailed. (Exception from HRESULT: 0x800706BE)"
    At E:\DailyBuild\Scripts\PublishTestResults.ps1:533 char:15
    + $ie.Navigate <<<< ($srcFile)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

  • Send local html files to Browser

    I have a Servlet program which can send any HTML files located on the computer which Tomcat is running to client browser. The HTML files are not necessarily in Tomcat's "webapps" folder. My method is quite simple. Read the content of the local HTML file and write it out through HttpServletResponse object. But there is problem that if the HTML file includes images, the images don't appear in client browser. Is there a way to send those images to client browse as well? Thanks in advance.

    Well, this is just an idea, but:
    You would probably have to create a new Servlet, that will identify the image type, set the correct content type (response.setContentType("image/gif") for example). It would have to get a binary InputStream to the image and copy the input to the output stream in the response(use the getOutputStream and not getWriter...)
    In your HTML writing servlet you would have to scan each line for an <img ... > tag parse out the source and replace it with the image servlet.
    Locating the image may be problematic if it is not given in absolute "file://" url. You may need to scan for a <base> tag in the HTML as well, or use the HTML page's directory for the path in which to find the image... but it could come in more complicated then that depending on how complicated the HTML was written (ie, for a server with multiple hosts, or with aliased paths...)
    Or, you might be able to write a filter that looks for images(*.gif *.jpg) and sends the request to your image servlet....

  • FF 10: cannot load local html files by dragging to FF; links in email don't open

    Just upgraded to FF 10. I cannot open a local html file by dragging it to to FF, or by clicking the file name. Clicking the file name brings up an error message: There was a problem sending the command to the program. Dragging just shows a circle with a slash.
    I can open a local file by typing "file///<file location>" in the location bar.
    Also, clicking a link in an email to any site does not open the site.

    Hi,
    Please see [http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox this]. You can start Firefox in [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode] to check if an add-on is causing the problem. You can also try to '''Open with''' by right-clicking on the HTML file and choose Firefox and enable '''Always use the selected program to open this kind of file'''.

  • Safari 5.1 does not open local html files

    Safari 5.1 does not open local html files (with .htm or .html extensions). It fails on files that previous versions of Safari opened. Firefox continues to open them. Any suggestions?

    Turn this option off:
    Regards,
    Colin R.

  • Opening up a local html file

    From within an authorware exe file I want to open an local html file.
    It can't seem to find it even though I put the relevant files in the same folder currently C:\EP
    here's my code:
    JumpFileReturn("\\EP103\\pe16\\pt1\\page_01.htm", "", "")

    Try JumpOutReturn("",FileLocation^"myfile.htm")
    Or  JumpOutReturn("",FileLocation^"MySubFolder\\MySubSubFolder\\MyFile.htm") depending on the file hierarchy.
    This should work.
    +27 82 853 1010
    http://www.jfmultimedia.co.za
    Skype:  johannfouche
    Telephone VOIP:  +27 127435670

  • Firefox will not automatically convert local pdf URL to include file:// like it does for local html files

    I have some local PDFs sorted by navigating some local html files. Firefox recognizes that the html files need to be addressed file:///C:/SD_Online/datasc.html. When clicking the link for a PDF it remains c:/SD_Online/L-R4-106.pdf and I get an error saying "Firefox doesn't know how to open this address, because one of the following protocols (c) isn't associated with any program or is not allowed in this context."

    Press the '''Alt''' or '''F10''' key to bring up the tool bar.
    Followed by; '''File > Open File.'''

Maybe you are looking for

  • Photoshop CS6 Will not open files\create new\function properly

    Hello, I have a licensed Photoshop CS6 installed on Windows 8.1 64bit. This morning the software has started to have the following issue: Photoshop will not create any new files (With the exclusion of spamming CTRL+N I have managed to open a new proj

  • Acrobat 9.0 Pro runtime error

    Hello! I just installed the brandnew Adobe 9.0 Pro. I can open it but after 3 seconds a runtime error appears: "Program C:\program files\adobe\acrobat9.0\acrobat.exe. This application has requested the runtime to terminate it in an unsusal way." I ha

  • Error when create a new asset ----ASSERTION_FAILED

    Hi, I have installed EHP4 FOR SAP ERP 6.0 / NW7.01 and when create new asset with AS01 and try to save the system show me the next runtime errors: ASSERTION_FAILED" " " CL_FAA_CFG_DEPRAREA_ERP=======CP" or "CL_FAA_CFG_DEPRAREA_ERP=======CM009" SETDAT

  • RFC to JDBC Sync. Scenario

    Hello Guys, I'm trying to set up a RFC - XI - JDBC Scenario. Where the RFC sends some parameters and the JDBC performs a SELECT Query. I have a RFC that already was imported with the following definition:   IMPORTING      VALUE(LOGIN) TYPE  STRING   

  • PSE 9 does not save transparant GIF's

    The background eraser in PSE 9 does not work correctly, in that it erases very small areas instead of size of the setting.  Then when I save a GIF transparant background the background is white.  I've just upgraded from PSE8 to 9, and did not have th