Saving textpane wrapped in htmleditorkit to an html file

Hey,
Do any of you people know what I am doing wrong with the following code? It will not take the typed text, convert it to html code, and save it as an html file. The file saves properly, but it is just blank w/ no text and such.
please help
          else if (mi == save)
               JFileChooser chooser = new JFileChooser();
             int result = chooser.showSaveDialog(this);
             if (result == JFileChooser.CANCEL_OPTION)
                 return;
             else
                    try
                         File loadFile = chooser.getSelectedFile();
                         OutputStream out = new FileOutputStream(loadFile);
                         htmlkit.write(out, htmldoc, 0, htmldoc.getLength());
                         out.close();
                    catch (Exception ex)
          }

Granted this is just a snippet of your code, but while you're talking about 'it' not taking the 'typed' text I had in my mind your keying in text in a JEditorPane or JTextPane. But it seems that you mean 'typed' into the file you're reading in.
Also, what is htmlkit ... I can't locate any such class in the 1.4.2 API ... am I missing it?
So, it sounds like you want to take a text file, read it in, then write it out as an html file. Am I right? In that case, if htmlkit is your own class, post the code for it.
I don't know if you'd want to try this, but it's any easy matter to write text to a JEditorPane or JTextPane with an attached EditorKet and write it out from there with code like this:
FileWriter fw = new FileWriter( loadFile );
fw.write( jtp.getText(), 0, jtp.getText().length() ); // jtp is the JTextPane
fw.close();

Similar Messages

  • Saving text generated by script as an html file

    Hi
    I have designed a script that generates text which I would like to save as an html file called 'index.html' on my desktop. Is it possible to do this using TextEdit or some other application?
    Thanks
    Nick

    You don't need to use an app to accomplish this. The following will take the contents of a variable myHTML, create a file test.html, write to it, and close it.
    If you are generating the HTML in a loop, you can write to the file as it's generated or - as here - put it all into a single variable and write in one go.
    You'll probably want to specify a complete path for the file!
    set myHTML to "some html"
    set theFile to open for access file "test.html" with write permission
    set eof theFile to 0 --empties file if it contains anything
    write myHTML to theFile
    close access theFile

  • Combining bookmarks .html files, and sorting

    Hi,
    (1) I know how to import bookmarks, but, once I import all of my bookmark .html files, (have 6)... than I go to show all bookmarks, I have 6 "unsorted bookmarks" folder tabs, and one "unsorted bookmarks" tab of my current bookmarks. How do I combine all of these into 1 giant .html file? Or is it automatically combined once I imported, to where I can export and it'll have all 6 old .html files and my current bookmarks?
    (2) I know how to sort bookmarks, and I like sorting by "location", but is there a way to export as .html file so it saves the .html book mark file by "location"?
    (3) In the .html file there is some sub description for each bookmark, such as "Twitter is a social networking site, where users tweet to other users blah blah", is there any way to delete this? I'd like it only to display the bookmark name and the URL (usually I'll have to click on the name and it'll open up the website), but I like the website to be typed out.

    -1- <br />Yes all those bookmarks.html files will be merged into Firefox, and when you 'export' from Firefox those 6 files will be in one html file. No those extra 'unsorted bookmarks' folders won't be automatically combined, you need to do that yourself.
    -2-<br />No, 'location' sorting isn't reflected in an exported bookmarks.html file. That type of 'sort' is temporary in the Library view, and doesn't rearrange bookmarks in the places.sqlite file which is what is exported in html format. <br />
    Save this code as a Bookmarklet and click on it to make an HTML page editable. <pre><nowiki> javascript:document.body.contentEditable='true';%20document.designMode='on';%20void%200</nowiki></pre>
    Once the page is 'editable', you will be able to cut and paste bookmarks from one place on the page to another.
    -3-<br/>This code when run in the URL bar ''(or saved as a bookmarklet)'' while a bookmarks.html file is being displayed in Firefox will strip the extraneous information from that bookmarks file. Just save the bookmarks file when the 'strip' is completed.
    <pre><nowiki>javascript:%20(function(){%20var%20ls=document.getElementsByTagName('*'),%20lsl=ls.length;%20for%20(var%20i=0;%20i<lsl;%20i++)%20{l=ls[i];%20l.removeAttribute('id');%20l.removeAttribute('last_charset');%20l.removeAttribute('icon');%20l.removeAttribute('ICON_URI');l.removeAttribute('last_modified');%20l.removeAttribute('last_visit');%20l.removeAttribute('add_date');%20l.removeAttribute('personal_toolbar_folder');}%20var%20e=document.getElementsByTagName('dd');%20el=e.length;%20for(var%20i=el-1;i>=0;i--)%20e[i].parentNode.removeChild(e[i]);%20alert('Cleanup%20Complete%20-%20Save%20as%20Web%20Page,%20Complete\n'+'('+lsl+'%20bookmarks,%20'+el+'%20descriptions)')})();</nowiki></pre>
    - brief explanation of Bookmarklets - <br />http://www.bookmarklets.com/ <br />http://en.wikipedia.org/wiki/Bookmarklet

  • HTML file and Word Wrap

    hi,
    i am saving a HTML file (downloaded from the web) ....
    i wanna know... how to set a Word Wrap... so it won't scroll to the right hand side....
    any ideas

    ok i think code will give you a better view of what i am trying to say
    try {
    URL hostURL = new URL("http://search.lycos.com/main/default.asp?lpv=1&loc=searchhp&query=USA");
    HttpURLConnection tc = (HttpURLConnection) hostURL.openConnection();
    FileOutputStream fs = new FileOutputStream("results.html");
    tc.setDoInput(true);
    tc.connect();
    String inputLine;
    BufferedReader in = new BufferedReader( new InputStreamReader (tc.getInputStream()));
    while(( inputLine = in.readLine()) != null )
    fs.write( inputLine.getBytes());
    fs.close();
    in.close();
    tc.disconnect();
    }catch(Exception e) { System.err.println(e); }
    HTML retrieved by this code is saved in a file "abcde.html"
    but this code copies whole HTML of the above page in a one line.... i was wondering is there
    any way to setWordWrap ( like insert newline char) so "abcde.html" is more readable

  • Saved as HTML only file, but open as notepad with a lot code. In other words, it is not HTML file format.

    I saved a file as HTML only. When I am going to open this file, I found the file showed a notepad icon. When I opened the file, it was totally code description with some words inside. It looked like program work showed up.
    I checked it again and saved it again with HTML only again. It was the same situation.
    I would like to have help.
    This computer I just brought and downloaded Firefox only several days ago. I never had this kind of problem on other computer
    Thank you for the help

    Can you post a short except of the file, so we can see what is looks like?
    You can paste the text between &lt;code&gt; and &lt;/code&gt; tags.
    If you save the page as an HTML file then you should get the page source with HTML tags like you see if you right-click on a web page and select View Page Source in the right-click context menu.

  • Firefox when saving a "complete html" file is downloading a folder and "2" copies of the html file not one. One of these has the same name but "0" kb content

    Hi. The only save options for a full html type file on Firefox is as "web page, complete" and as I say when saving with Firefox the program is saving the usual yellow folder with links and artwork files etc, but is saving 2 copies of the HTML file where on of these files is empty, won't open and gets locked to the destination it was saved to. This empty file can't be moved, and can't be deleted. When this is attempted it gives message "cannot delete (or "move" if this is the case) : Cannot read from the source file or disc."
    To overcome this I now use Internet Explorer, dut prefer not to. I have also deleted Firefox from my system and re-installed it, but this did not help. How can I stop this doubling of saved files? and how can I delete the ones that are now fixed to my desktop? can you lease help?

    You said, ''Would like to sort this one out...any clues?''
    Maybe something here will help:
    *http://en.wikipedia.org/wiki/MHTML
    *http://en.wikipedia.org/wiki/Mozilla_Archive_Format
    *http://maf.mozdev.org/
    *http://maf.mozdev.org/documentation.html

  • Bookmarks are saved but as folders & html files, i want to import in mass not one at a time but system won't let me select all from folder

    computer was infected by virus rebuilt after save but bookmark favorites saved as html files in folders not bookmark format

      Yes, I tried that.   The files were ordered by their original numbers as imported from the camera, but I batched them through Phocoshop to downsize all of them into a more manageable file size.   I opened that destination folder from quick time  from where it said select image sequence.   I clicked on the first one and opened it.   The result was a large image with an arrow indicating a movie was ready to go.   When I pressed the arrow, though, I realized it had only imported that one frame so there was no movie.   The files are Jpgs and are about 450 KB each. 
        To your knowledge are there any links to iMovie tutorials or quick time tutorials that may address this situation?  Maybe there will be one I haven't looked at yet. 
        Thanks

  • I had to re-install firefox recently and lost all my bookmarks and passwords, how do I retrieve them? I have already saved them as an html file on my desktop.

    I've been having problems with my computer, and had to delete Firefox entirely several times. I don't believe it was your browser that was the problem, though now I have lost all my saved bookmarks. I did export them to IE as an HTML file, which I still have on my desktop. I am now in the painful process of remembering and resetting passwords that Firefox remembered when I had it originally installed (I am back at ground zero with the browser now).

    Please read this article about restoring bookmarks:
    http://kb.mozillazine.org/Lost_bookmarks
    As far as your passwords are concerned, I don't think there's anything you can do. But for the future, you can use the following add-ons to avoid any future loss:
    https://addons.mozilla.org/en-US/firefox/addon/2848/
    or
    http://www.xmarks.com/
    Both are good.
    And a simple way to import your bookmarks (since you already saved it on your desktop as html) is:
    Bookmarks / Organized Bookmarks / Import and Export
    Good luck.

  • I saved web page as html file, but can't open saved file as web page

    I did a FILE, SAVE PAGE AS, then chose 'WEB PAGE COMPLETE' - and a directory is created on my hard drive - with the directory name, for example - "c:\....\Ask a Question _ Mozilla Support.htm". (for this web page).
    When I try to open the saved web page from Firefox, using FILE, OPEN, I see a new window that looks like a file manager window, I then select that saved .html file and click OPEN, and a new window opens that looks like file manager - displaying with all the files in that directory - "Ask a Question _ Mozilla Support.htm". That is, it does not open and dislpay the web page as I expect it should (that I saved earlier).
    However, if I go to the file manager, I can see that directory is saved, and has the Windows Explorer icon associated with the directory "ask a question ....html", and also has a file type of HTML listed. If I double click that directory in file manager, Windows Explorer will open that directory and dis[play it as a web page, as I expected.
    I would like to know why Firefox does not open the directory name as a web page from the FILE, OPEN command, but instead shows me the directory contents(all the files in that directory)?
    BTW, if I try FILE, OPEN, using Windows Explorer the same thing happens - it opens a new window listing all the files in that directory.
    Is this the way the FILE, OPEN is supposed to work?
    It seems confusing, because if I am in any other program, for example WinWord, and do a FILE, OPEN command on a Word file, it opens the file as a Word Document - it does not just show the file in a "file manager window.
    But when I click FILE, OPEN on an HTML file(directory using Firefox, it does not open that html directory as a web page?

    I am in the Windows Explorer 'Details' view, and I see the folder with 'Type' of FILE FOLDER. In that folder are all the .js and .css and .png files - as cor-el said.
    ''But now I also see'' that there is also an htm file - ''with the exact same name ''as the folder, but it has a 'Type' of 'HTML Document'. When I have Firefox do a File, Open on the HTML Document - it does open the web page that I saved and does display it as a web page.
    I did not realize that Firefox saves both:
    1) a Directory '''(Type 'File Folder') '''''', and,
    2) an html file''' (Type 'HTML Document')
    ... '''and that they are the exact same names! '''
    I was clicking on the wrong one! Instead of clicking in the .html file, I was incorrectly clicking on the folder!
    (The archive add on looks interesting, but shouldn't I be able to open the saved web page, from the browser, using File, Open File) ?

  • Using Firefox 3.6.20 and Windows XP Home SP3. Firefox sporatically deletes bookmarks from the bookmarks toolbar. Additionally, when I try to import from a saved HTML file, Firefox does not import the complete file. Results are inconsistent.

    Using Firefox 3.6.20 and Windows XP Home SP3. Firefox sporatically deletes bookmarks from the bookmarks toolbar. Additionally, when I try to import from a saved HTML file, Firefox does not import the complete file. Results are inconsistent.

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  • Both Firebox and IE open home page instead of saved http html files on HDD

    This didn't happen before, only in the last 3 days. Didn't install anything on PC other than Itunes and possibly - automatic updates on Win 7.
    The ONLY way to open saved html file is by right-click: Open With -> Choose Default Program -> Firefox.
    It doesn't open the file on double click, or on right click: Open With -> Firefox, or right click: Open With -> Choose Default Program -> IE, in all 3 cases it goes to homepage.
    There was adware or malware Rollup File Opener that I uninstalled but still see some remains in Troubleshooter.

    hello almot09, apparently you still have remnants of this adware in ''firefox > addons > extensions''.
    please run a full scan of your system with different security tools like the [http://www.malwarebytes.org/products/malwarebytes_free free version of malwarebytes] & [http://www.bleepingcomputer.com/download/adwcleaner/ adwcleaner] which are specialised in removing browser hijackers.
    another user with a similar issue has reported, this could resolve the problem: https://support.mozilla.org/en-US/questions/986102

  • Simple Browser which support locally saved html file having Marquee text

    I want simple java browser in which I can run locally saved html file having marquee text in it.
    My requirement is to show html file in Oracle forms.For that i need JAR Files of that browser which support html file(locally saved & support marque text).
    Because i use several browser which support locally html file but not support marque text.These browser display static html file not marque text in it.
    Can anybody help me.
    Regards

    1. There is no reliable way of guessing the encoding of a file without that information. Thats why XML for example has very strict rules wrt. it's encoding (short form: use UTF-8 or UTF-16, if you use anything else, you'll have to specify it)
    2. you might be able to make an educated guess if the possible range of encodings is limited, but it will probably never be 100% certain
    3. The HTML file might have a header entry "<meta http-equiv..." that tells you about it's encoding. You could try to read the start of the file and see if you find that, then if you found it re-read the entire file.
    regards

  • Previous saved bookmarks.html files were almost twice the size. If I rely on this much smaller folder for saving my I may lose bookmark data. Can someone explain why my folder is now suddenly so much smaller?

    Since I upgraded to 3.6.3 my bookmarks folder has become nearly half the size upon exporting it in html format. I normally refresh my working copy of Mozilla by saving the bookmarks and then erasing all aspects of Firefox and starting over from scratch. I am concerned that if I rely upon this smaller folder I may be losing data. Can someone tell me what is happening here? It could be that this is just an improvement in Firefox but I do not know how to test the waters to see if all my data is saved.

    Are you comparing the size of the bookmarks.html file that is exported from Firefox 3.6.3 to a bookmarks.html file that was exported from earlier versions of Firefox?
    Really shouldn't be a difference, there hasn't been a change to Firefox regarding the bookmarks.html file in years.

  • Saved HTML Files

    Saving an InDesign CS 4 file as html (export to swf) for a web page. When the html files opens in Safari there is a border on the left and the top so the page seems placed wrong to the lower right. I've tried a variety of Page Setup settings including the Above recommended but despite the changes in page sizes there seems to be no getting rid of that left and top border.  Any suggestions?

    There´s another discussion about this subject:
    http://forums.adobe.com/thread/443084

  • Web browser for running locally saved html file with Marquee Text

    I have a html file contain Marquee text.
    I want to display that html file in oracle forms(10g).
    I already use simple html browser but it does not support marquee text.
    I already tried to convert the html file into Gif file but Marquee text not appear in gif file.
    Is there any browser which support the locally saved html file with marquee text and also it can be embedded in oracle form.
    Or is there any way for display that html file within the oracle forms.
    Remember I don't want to display that file in separate window.I want to display that html file within the form.
    Regards

    Actually that is what I was doing last night and got a bad flash and bricked my router..so its on its way back to Linksys...

Maybe you are looking for