URGENT : Viewing HTML files & UNICODE characters

I do not know how to view HTML files in Java2. I have various HTML files which I would just like to display in the ContentPane of a Dialog Box.
Please let me know how should I do it.
Also, I have another question. How do I display Unicode characters like the alpha and the beta even after I know their hexadecimal values? I would like to display them as text on a JLabel. But the intended character doesnt appear. Instead, what appears is a black empty square in its place. Please let me know how to rectify this.

You can use JEditorPane to display HTML file.You can dislpay alpha and the beta characters by
jlabel.setText("\u03B1\u03B2");
where 03B1 is unicode value for alpha and 03B2 is unicode value for beta.
You can get unicodes for Greek from following link.
http://www.unicode.org/charts/PDF/U0370.pdf

Similar Messages

  • Viewing html files in a folder...

    Hi...
    Anyone know how to view html files in a folder(s). What i mean is have them display as thumbnails, etc, so one can identify them visually rather than just by name? Abit like Bridge displays image files and even .psd and .ai files....
    Cheers,
    JJ

    martcol wrote:
    I was interested in this and had a Google around.  It struck me that you can get stand alone file viewers and I thought there must be one for HTML?  I came accross this: http://www.anixsoft.com/htmlview.html
    Absolutely no idea what it might be like but I'm willing to give it a try at the weekend.  Maybe there are others out there?
    Martin
    Googled too... but found nothing interesting... except what seems an old hack from a Microsoft guy who had a registry fix. But the link was very old...
    Anyway, have downloaded the link you gave... thanks... it seems to work as a standalone... almost like an image viewer such as irfan or Xnview...
    Cheers,
    JJ

  • Kindly help me how to view html file in swing using jbutton

    hello..im a begginer at j2se language and im working on my school project..kindly help me how to view html files by clicking button at javax.swing..thanks

    Here you go:public class HTMLViewer implements Runnable, ActionListener
         public void run() {
              JFrame frame = new JFrame("View HTML");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JButton button = new JButton("Click me!");
              button.addActionListener(this);
              Container cp = frame.getContentPane();
              cp.add(button, BorderLayout.CENTER);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         public void actionPerformed(ActionEvent e) {
              if (Desktop.isDesktopSupported()) {
                   Desktop d = Desktop.getDesktop();
                   try {
                        d.browse(new URI("www.google.com"));
                   } catch (IOException ex) {
                        ex.printStackTrace();
                   } catch (URISyntaxException ex) {
                        ex.printStackTrace();
         public static void main(String[] args) {
              EventQueue.invokeLater(new HTMLViewer());
    }If that's not what you're looking for you need to ask more specific questions.

  • Setup to view html files

    I am new to weblogic Is there a way to setup weblogic to view html files I have 8.1

    private void openURL(String url) {
              String osName = System.getProperty("os.name");
              final String errMsg = "Error attempting to launch web browser";
              try {
                   if (osName.startsWith("Mac OS")) {
                        Class fileMgr = Class.forName("com.apple.eio.FileManager");
                        Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
                        openURL.invoke(null, new Object[] {url});
                   else if (osName.startsWith("Windows"))
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
                   else {
                        //assume Unix or Linux
                        String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
                        String browser = null;
                        for (int count = 0; count < browsers.length && browser == null; count++)
                             if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
                                  browser = browsers[count];
                        if (browser == null)
                             throw new Exception("Could not find web browser");
                        else
                             Runtime.getRuntime().exec(new String[] {browser, url});
              } catch (Exception e) {
                   JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
         }

  • How to write to file Unicode characters

    I have PDF files that I need to copy some strings out of and put them in various fields in a Postgres database. The goal is a Java screen into the database, whiere I mark and copy the PDF text and then paste it into a field in a Swing window, and from there into the database.
    I am unsuccessful at reading a PDF file, so I have opted to cut and paste the PDF file into an MS word file. This results in errors in certain unicode characters. I am trying to rectify them by a simple program, a start of which is below, by a replacement of the erroneous char by the proper unicode symbol. As, shown by the following, I cannot figure out how to write out a unicode character. Do I need to wrap (which I don't know much about yet)? Or do I have a file problem? (I have a Vista machine.) I don't think it should be impossible to write unicode into a file, as I am able to write into MS Word files phonological symbols, Russian, and Sanskrit. So, it must be in the java.
    P.S.: I am reading Schildt's Java: A Beginner's Guide and am through chapter10, but remaining chapters are on threads, enumerations, autoboxing, static import, annotations; generics,; applets, events, and miscellaneous topics, and, finally Swing. Maybe its in the autoboxing?
    Any help would be most appreciated.
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.io.IOException;
    public class CopyCharacters {
    public static void main(String[] args) throws IOException {
    FileReader inputStream = null;
    //FileWriter outputStream = null;
    PrintWriter outputStream = null;
         char longa = 0x0101;
         int longc = 0x0101;
         char capA = 0x0041;
         char longb = 0x0111;
    // Unicode for uppercase Greek omega character char uniChar = '\u039A'
         char uniChar = '\u039A';
    // Character ca = new Character('0x0101'); // illegal
         Character cb = new Character('\u0101');
         Character cc = '\u0101';
    int c;
    try {
    inputStream = new FileReader("Cardona1.txt");
    outputStream = new
                   PrintWriter(new FileWriter(
                        "characteroutput.txt"));
              outputStream.println( "character1 " + capA); //yields A
              outputStream.println( "character2 " + longa); //yields ?
              outputStream.println( "character3 " + '\u0101'); //yields ?
              outputStream.println( "character4 " + longc); //yields 257
              outputStream.println( "character5 " + "S\u00ED Se\u00F1or"); // yields character Sí Señor
              outputStream.println( "character6 " + "S'\u00ED' Se\u00F1or"); // yields S'í' Señor
              outputStream.println( "character7 " + "S\u0121 Se\u00F1or"); // yields character S? Señor
              outputStream.println( "character8 " + "S'\u0121' Se\u00F1or"); // yields character S'?' Señor
              outputStream.println( "character9 " + uniChar);// yields character ?
              outputStream.println( "character10 " + '\u00FF');// yields character ÿ but fails on \u0100.
    // only 0-255!!
              outputStream.println( "character11 " + cc);// yields ?
              outputStream.println( "character12 " + cb);// yields ?
              outputStream.println( "character13 ?");// yields ?
    while ((c = inputStream.read()) != -1) {
         // outputStream.writeln(c);- error
    } finally {
    if (inputStream != null) {
    inputStream.close();
    if (outputStream != null) {
    outputStream.close();
    }

    I am unsuccessful at reading a PDF file, so I have opted to cut and paste the PDF file into an MS word file. This results in errors in certain unicode characters.Stop right there. You are digging a hole. Stop digging. Fix the problems with reading the PDF file.

  • Viewing HTML file

    i don't know how to view an html file, is there a command that let me call the explorer and load the file ?
    or is there a container or a class that shows html files ?
    thanks

    Creating HTML through Microsoft Word is not a good idea, it has to create the worst HTML I have ever seen. However to get your links working you will need to write a hyperlink listener. Theres an example in the javaDoc for JEditorPane http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/JEditorPane.html

  • Viewing HTML files and Overriding a portlet

    Dear reader:
    I need to view an HTML file in a portlet according to a specified parameter passed via URL address, can i use url.display_url or not, and how? and if not what should i use?
    and related to that how can i call a portlet (or a page published as portlet)to override an existing one (programatically)?
    thank you for your time.

    To bring in content from another url, I've used code similar to the following within a Dynamic Page portlet with alot of success...
    <html>
    <table>
    <tr><td>
    <iframe
    src="http://www.domain.com/blablabla" noresize hspace="0" vspace="0" frameborder="0"
    marginheight="0" marginwidth="0" width="620" height="400">
    </iframe>
    </td>
    </tr>
    </table>
    </html>

  • How to view html files

    Hi,
    i had created a frame with a button..now i need to execute a html file not inside the frame, but in a web browser on click of the button how to do....

    private void openURL(String url) {
              String osName = System.getProperty("os.name");
              final String errMsg = "Error attempting to launch web browser";
              try {
                   if (osName.startsWith("Mac OS")) {
                        Class fileMgr = Class.forName("com.apple.eio.FileManager");
                        Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
                        openURL.invoke(null, new Object[] {url});
                   else if (osName.startsWith("Windows"))
                        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
                   else {
                        //assume Unix or Linux
                        String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
                        String browser = null;
                        for (int count = 0; count < browsers.length && browser == null; count++)
                             if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
                                  browser = browsers[count];
                        if (browser == null)
                             throw new Exception("Could not find web browser");
                        else
                             Runtime.getRuntime().exec(new String[] {browser, url});
              } catch (Exception e) {
                   JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
         }

  • View HTML file in MIDP 2.0

    Hi,
    Is anyone aware of a library available that can be used for rendering local HTML files in a MIDP 2.0 project?
    I read some places that Sun was going to release an xHTML library but all links go to dead ends.
    Any advice would be greatly appreciated.
    Jim

    Hello,
    We can read or scrap html file from your apps.
    Sun has provide some article on the same.
    http://developers.sun.com/techtopics/mobility/midp/ttips/scraping/index.html
    go throught the article and i hope this will give you a idea at present.

  • Web sharing - viewing html files from Mac to PC

    I am creating a website using QuarkXpress. Now I uploaded my html and image folder directly to my Site folder. My client has a PC, but cannot open the http address to view the page. Web sharing is on, also file sharing. What did I miss?? Thanks for your help.
    I highlighted websharing in system preferences and gave my client my computer address. But the page does not load?
    What's the difference from a remote computer and local IP range? I am confused there???

    Do you have more than one device connected to your Router or Modem?
    To see the difference between local & Remote, compare your IP in System Preferences>Network>TCP/IP tab & what your outside IP is...
    what's my ip...
    http://www.whatsmyip.org/

  • View HTML file in application server in MPP

    Hi,
    I have a html index file and a bunch of other files accessed by the index file in a specific directory on the SAP server. I would like to display the index file on click of button created in MPP.
    How to achieve this ? Any idea ?
    Thanks,
    K.Tharani.

    check the value of sy-subrc for open and close dataset statements so that you would know whether the file was opened and closed correctly.
    Regards,
    Sumit

  • View local html files

    Does anyone here know how to view html files which are stored locally on iPhone?
    Thanks

    Unfortunately, iPhone Safari doesn't support the "file://" protocol.
    Not having local storage of web apps was, and is, a big limitation.
    Some companies I contract to, have large business apps written under IE6 on handheld Windows CE devices. The apps are stored on the device. When the iPhone (and Safari Windows) came out, we thought about modifying them to run under Safari. The limitation stopped that idea.

  • Viewing Dreamweaver files in Word 2007

    When viewing html files from Dreamweaver CS4 in Word 2007 the text is right-shifted on the page. It displays fine in all previous versions of Word but not with 2007. I have tried the various advanced options, compatibility settings to no avail. I have tried resetting office back to factory settings (including the document templates) but it still doesn't work. I decided to post this here in case anyone has had a similar issue opening files from dreamweaver to Word 2007.
    Any help would be greatly appreciated.
    John

    I'm with Murray here.
    It's a recipe for disaster and you'll no doubt end up being asked to fix it.
    There are many better ways of allowing clients to edit websites without opening the site to wholesale destruction.

  • Create HTML file that can display unicode (japanese) characters

    Hi,
    Product:           Java Web Application
    Operating system:     Windows NT/2000 server, Linux, FreeBSD
    Web Server:          IIS, Apache etc
    Application server:     Tomcat 3.2.4, JRun, WebLogic etc
    Database server:     MySQL 3.23.49, MS-SQL, Oracle etc
    Java Architecture:     JSP (presentation) + Java Bean (Business logic)
    Language:          English, Japanese, chinese, italian, arabic etc
    Through our java application we need to create HTML files that have to display unicode text. Our present works well with English and most of the european character set. But when we tried to create HTML files that will display unidoce text, say japanese, only ???? is getting displayed. Following is the code we have used. The out on the browser displays the japanese characters correctly. But the created file displays only ??? in place of japanese chars. Can anybody tell how can we do it?
    <%
    String s = request.getParameter( "txt1" );
    out.println("Orignial Text " + s);
    //for html output
    String f_str_content="";
    f_str_content = f_str_content +"<HTML><HEAD>";
    f_str_content = f_str_content +"<META content=\"text/html; charset=utf-8\" http-equiv=Content-Type></HEAD>";
    f_str_content = f_str_content +"<BODY> ";
    f_str_content = f_str_content +s;
    f_str_content = f_str_content +"</BODY></HTML>";
    f_str_content = new String(f_str_content.getBytes("8859_9"),"Shift_JIS");
    out.println("file = " + f_str_content);
              byte f_arr_c_buffer1[] = new byte[f_str_content.length()];
    f_str_content.getBytes(0,f_str_content.length(),f_arr_c_buffer1,0);
              f_arr_c_buffer1 = f_str_content.getBytes();
    FileOutputStream l_obj_fout; //file object
    //file object for html file
    File l_obj_f5 = new File("jap127.html");
    if(l_obj_f5.exists()) //for dir check
    l_obj_f5.delete();
    l_obj_f5.createNewFile();
    l_obj_fout = new FileOutputStream(l_obj_f5); //file output stream for writing
    for(int i = 0;i<f_arr_c_buffer1.length;i++ ) //for writing
    l_obj_fout.write(f_arr_c_buffer1);
    l_obj_fout.close();
    %>
    thanx.

    Try changing the charset attribute within the META tag from 'utf-8' to 'SHIFT_JIS' or 'utf-16'. One of those two ought to do the trick for you.
    Hope that helps,
    Martin Hughes

  • Saving html file with Unicode character(Japnese)

    Hello,
    I am having some data in table with japnese characters.
    I want to save html file which contains above data in table format and open this file in excel.
    I am using
    new String(str.getBytes("ISO8859_1"),"UTF8");
    which gives me desired output in browser(using servlet). but when i write to file, same output using BufferedWriter.
    it gives me "????".
    Is there in other way to do it.

    don't you need "UTF16" as the encoding if you want extended Unicode?
    I think the Writer might strip off upper 8 bits if you specify UTF8.
    Just a thought, though I haven't tried it, so it may be a red herring.

Maybe you are looking for