Text formatted like Java code

I was going to put some examples of java code on a website that I'm currently building, what is the easiest way to format the HTML to look like some of the code examples used in these forums? Could I do it with a stylesheet or XML or would I have to do something really complicated?

Just use normal html: heres a template:-
<html>
<title>* Your title *</title><head><h4>AProgram.java</h4><hr></head
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body bgcolor='white'>
<table border=0 cellPadding=2 cellSpacing=0 width="100%">
<TR><td width="8%"></td>
<td width=80%></td><td></td></tr>
<tr></td><td><td><font face='Courier' size='3' color='black'>
public class AProgram {
</body>
</head>
Don't use the <pre> tag as cuases the text to be unusually spaced or to come out tiny for those using resolutions above 800 x 600 and you'll need to hand code certain things eg;-
     space = & nbsp ; // close the spaces
     left tag '<' = & lt ; // close the spaces
     right tag '>' = & gt ; // close the spaces

Similar Messages

  • Compile source string like java code

    I need to calculate some user defined formulas in my application. I have this formula in string form (e.g. "operand1 * operand2 + operand3" ). I have gained operand values throught the reflection and pars this string throught the StringTokenizer. So I have parsed string with operand values and operators. Is it possible to compile this string like java code ?
    Thanks for all hints

    Compile to what - a class file?
    Yes, it's possible if you don't mind using non-100% pure Java. You can compile them using the sun.tools.javac.Main class found from tools.jar in the lib directory of the jdk.
    But from what you say it would be easier to use an existing expression evaluator. Take a look at JEP (jep.sourceforge.net) and BeanShell (www.google.com) before you make any decision.

  • Fill a text file from java code

    Hello,
    I've written a java code to insert some informations in a database and
    I also want to save the same informations in text files (.txt).
    Thanks you for your suggestions or your advice of a tutorial that can help me to perform successfully this task.
    J.S.

    Writing to a file is pretty easy in Java. A simple way is to use the PrintStream class.import java.io.*;
    public class MyClass {
      public static void main(String[] arg) throws IOException {
        PrintStream ps=new PrintStream(new FileOutputStream(new File("someTextFile.txt")));
        //now use println(String) to write lines of text to the file
        ps.println("This is a line in the file");
        //always close the PrintStream when finished
        ps.close();
    }Alternatively, for a good tutorial, click the 'Tutorials' link in the left column on this page.

  • Why is my text formatting like this?

    Hi
    I've set up my .css so that the <H2> is big and bold,
    and that my <p> text is smaller and normal. The problem is
    that I'm getting a line break gap between the two even when there's
    not one in the HTML. There should be a space between the <p>
    and <H2> (padding of 5), but not the <H2> and
    <p>. The HTML is:
    <h2>Designers - </h2>
    <p>enter your designs</p>
    <h2>Everyone -</h2>
    <p>vote for your fav designs<br />
    Here's the .ccs:
    h2 {
    font: Verdana, Arial, Helvetica, sans-serif;
    color: #69DB33;
    font-size:18px;
    font-weight: bold;
    text-align: center;
    padding-top: 5px;
    p {
    text-align: center;
    FONT-SIZE: 13px;
    COLOR: #847d6e;
    FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif;
    font-style: normal;
    So it kinda looks like this (layout-wise):
    Designers -
    enter your designs
    Everyone -
    vote for your fav designs
    instead of :
    Designers -
    enter your designs
    Everyone -
    vote for your fav designs
    I know I could probably do all the formatting in HTML, but I
    should be able to do it all in .css - can anyone help?
    Cheers
    Shaun

    Your interpretation is correct. Show us the code where it is
    not working
    for you, please.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Reese" <[email protected]> wrote in message
    news:esfsaq$ms9$[email protected]..
    > "Joe Makowiec" <[email protected]> wrote in
    message
    >
    news:[email protected]..
    >> On 04 Mar 2007 in macromedia.dreamweaver,
    celebritymusic wrote:
    >>
    >>> I've set up my .css so that the <H2> is
    big and bold, and that my
    >>> <p> text is smaller and normal. The
    problem is that I'm getting a
    >>> line break gap between the two even when there's
    not one in the
    >>> HTML. There should be a space between the
    <p> and <H2> (padding of
    >>> 5), but not the <H2> and <p>.
    >>
    >> You want margin, not padding. The diagram here might
    make it clearer:
    >>
    >>
    http://www.w3.org/TR/REC-CSS2/box.html
    >
    > According to that graph, if I apply a background on a
    30px wide div and
    > add 10px padding, the text inside will occuppy only 10px
    (30px - (2 x
    > 10px)), but an applied background would fill all 30px.
    But every time I
    > try it, the background image is just as limited as the
    text is. I can't
    > get the background to fill the padded area.
    >
    > How would I tell a DIV to push the text 10px off all
    four sides, but
    > continue to allow the background image to cover the
    entire div?
    >

  • Picures gone,all text format,(like in e-bay) how do I get them back

    I down loaded some add on, to keep the font enlarged (after I added no squint) and the web pages are all text. The pictures and back ground are gone. My e-bay is all text....I don't like it. How do I get the normal view web pages back ?

    [https://support.mozilla.org/en-US/kb/How%20to%20clear%20the%20cache#w_clear-the-cache Clear your browser cache].
    If needed, delete the site's cookies. <br />
    Right-click the page, choose View Page Info > Security > "View Cookies"

  • Writing data to a text file in a java code

    hey,
    can anybody tell me how can i enter data into a text file using java code.
    thanx

    yeah this is the proper answer....
    i had also a pblm ..that i had to read data from an excel sheet and write it to a File thru java code ....
    u can also use FileOutPutStream object....if u want...
    but there u can give newLine()..so all ur output will be in a single line to the file....
    bufferWriter.write(stringToBeWritten);
    bufferWriter.newLine();
    the stringToBeWritten can be a hardCoded string value..or any dynamic value like say fetching from database...

  • Java code to convert XML file to ISO XML format

    Hi Experts,
    I need to convert an XML file to ISO Xml format using Java code.I dont have any idea about the ISO XML format.I searched but what i am getting is ISO is an encoding in XML.
    It will be very helpful if any one can give me a sample ISO XML file, and any way around to carry out the required conversion.
    Thanks .
    Anika

    Hi,
    For ISO encoding you need the XML file to be converted with below providing the encoding paramter as ISO. for e.g.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    instead of
    <?xml version="1.0" encoding="UTF-8"?>
    this can be possible with using XML encoders.
    Refer XML encoding--> http://www.w3schools.com/XML/xml_encoding.asp
    Refer Java Code with uasage of XMLEncoder
    http://java.sun.com/j2se/1.4.2/docs/api/java/beans/XMLEncoder.html
    Thanks
    Swarup

  • DECODING MAIL FROM WEB SERVER IN PLAIN TEXT FORMAT(THE MAIL BEING SENT BY LABVIEW APPLICATION)

    Hi All
    I have a labview application that send mail every hour automatically.
    But actually the mail has to be decoded from the web server(by another application).But now when that application decode the data in the mail(that is send by labview application)its getting some funny characters inside that can not be detected by the decoding application
    (When open the mail no problem.)But actually our goal is to decode the mail from the web server.
    Why the extra characters are appearing when decoding from the server?Is it because of the HTML format?
    Is there option to send the mail in plain text format(not like attachment)?
    In outlook we can change the setting (tools->options->send->mail sending format->....here we can set as HTML format/Plain Text format)
    Like that at the sending time can i chenge the sending option as plain text format in my labview application?
    Thanks...

    smercurio_fc wrote:
    Then it sounds to me like this other application is not decoding the attachment correctly, especially if you looked at the attachment yourself after you received it and verified it's correct.
    No, no, smercurio. This is charcter encoding here. In older versions of LabVIEW you could specify what character encoding to use when sending an email through the SMTP VIs. But that gave problems since people in certain locales used certain characters that where not transfered right when the wrong encoding was specified, and that encoding stuff is not understood by most people at all, so the wrong selected encoding was rather the rule than the exception. In newer versions of LabVIEW do the SMTP VIs handle the encoding automatically based on the currently used locale on the system.
    This change is documented in the Upgrade Notes of LabVIEW and probably happened around LabVIEW 7.1 or 8.0.
    A decent mail client will recognize the encoding and convert it back to whatever is necessary before presenting it to the user. The OPs posters server application obviously isn't a smart mail client but probably just some crude text file parser that has no notion of proper mail character encoding and how to deal with it.
    I would suppose that there is a chance to dig into the SMTP VIs itself and try to manipulate or disable that encoding altogether in there but that may open a whole can of worms somewhere else. The proper way would be to process the incoming mail by a character encoding aware mail client before passing it to the text parser. On Unix setting up something like this would be fairly trivial.
    Rolf Kalbermatter
    Message Edited by rolfk on 01-23-2008 10:21 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Unable to update plugins because the "Plug-in Status" page returns in plain-text format

    From within the Add-ons Manager, I clicked on "Check to see if your plugins are up to date". When the status results page displayed, it was in plain-text format, like this:
    Potentially vulnerable plugins
    Plugin Status Action
    Outdated Plugins
    Plugin Status Action
    Unknown Plugins
    Plugin Status Action
    These plugins are up to date
    Plugin Status Action
    There's nothing to click on to update a plugin. I'm experiencing this plain-text formatting style anytime I open Add-ons Manager -- even when I search for new add-ons.

    Go back to that page. Then, while holding down the shift key, reload the
    page. You can also try these;<bR><BR>
    Clear the Cache '''''Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"'''''<BR><BR>
    and<BR><BR>
    Remove Cookies '''''Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"'''''<BR><BR>
    If there is still a problem,
    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]'''''
    <BR>While you are in safe mode;<BR>
    '''''Firefox Options > Advanced > General'''''.<BR>
    Look for and turn off '''Use Hardware Acceleration'''.

  • Translate the string source like java source

    I need to calculate some user defined formulas in my application. I have this formula in string form (e.g. "operand1 * operand2 + operand3" ). I have gained operand values throught the reflection and pars this string throught the StringTokenizer. So I have parsed string with operand values and operators. Is it possible to calculate this string like java code ?

    Mayba possible. But why you dont convert the Strings in primitve types? You have just using static methods in the Wrapper classes like: Integer.parseInt(String), Double.parseDouble(String) and so on. The operators you can convert in a charakter and use
    switch (operatorChar):
    case '+' : ...
    case '-' : ...
    Take a look at the java.lang.Compiler, if you still want create bytecode.

  • How to get the source code of an HTML page in Text file Through java?

    How to get the source code of an HTML page in Text file Through java?
    I am coding an application.one module of that application is given below:
    The first part of the application is to connect our application to the existing HTML form.
    This module would make a connection with the HTML page. The HTML page contains the coding for the Form with various elements. The form may be a simple form with one or two fields or a complex one like the form for registering for a new Bank Account or new email account.
    The module will first connect through the HTML page and will fetch the HTML code into a Text File so that the code can be further processed.
    Could any body provide coding hint for that

    You're welcome. How about awarding them duke stars?
    edit: cheers!

  • Java Code in a text file

    Hi,
    I need an information if whether anything like this can be done in java or not !!
    The requirement is to place the jave code statements into a text file and dynamically execute these statements which have been placed in the file. for eg: if a text file "test.txt" contains a statement
    System.out.println("Hello world"); without the class being defined or the main method being defined. I need to execute this statement and print out hello world on the console.
    is this possible ???
    I would be using JDK 1.2 or 1.3 for this but certainly not 1.4.x and above
    please do let me know if this problem can be tackled in anyway !!
    Thanks in advance !

    I'd suggest first checking to see if the code in question would also be valid code in an interpreted language like Javascript, Groovy, or BeanShell.
    If it is, then use an interpreter for the appropriate language, an interpreter written in Java and which you can plug into the Java program you're using.
    Otherwise, I suppose you could wrap a class and method around the code, and compile and run that.

  • Html code stored in text format, get back in html format

    Hello All, I am not much in to Database, but for one of our BI Development, we need this. We have a column which stores the html input from a webpage in text format. for example: '
    ' is stored in DB as '<html>' '<' and '&gt' are codes for < and > symbols. so is there any way to get the values from the DB in the HTML format like < and >. there are many other characters, not just these 2. If someone can point to, if we have any predefined function if we can convert into HTML? Thanks a lot in Advance, Regards, KN

    I can't really tell from your description, but it sounds like you are doing it wrong and should do this: Oracle® XML DB Developer's Guide Contents

  • How to read/write text file to db2 by using java code

    Hai
    I created the table to insert a clob data as follows
    db2 => create table ctest(datas clob(65536))
    DB20000I The SQL command completed successfully.
    db2 => describe table ctest
    Column Type Type
    name schema name Length Scale Nulls
    DATAS SYSIBM CLOB 65536 0 Yes
    1 record(s) selected.
    I tried the following java code to insert a clob data.
    public static synchronized Connection getConnection() throws Exception {
    Connection m_connectionDatabase = null;
    try {
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    // Get the connection to the database.
    m_connectionDatabase = DriverManager.getConnection(
    "jdbc b2 ps","","");
    }catch (Exception e) {
    throw new Exception("Failed to connect to the database. ", e);
    return m_connectionDatabase;
    public static void main(String a[]) {
    File file = new File("d:\\a.txt");
    InputStream fis = new FileInputStream(file);
    Connection con = getConnection();
    PreparedStatement pstmt = con.prepareStatement("insert into ctest values(?)");
    //try 1
    pstmt.setAsciiStream(1,fis,(int)file.length());
    // try 2
    pstmt.setCharacterStream(1,fis,(int)(file.length()));
    // try 3
    pstmt.setBinaryStream(1,fis,(int)(file.length()));
    // try 4
    byte[] b = new byte[fis.available()];
    fis.read(b);
    pstmt.setBytes(1, b);
    // try 5
    byte[] b = new byte[fis.available()];
    fis.read(b);
    pstmt.setString(1, new String(b));
    pstmt.executeUpdate();
    pstmt.close();
    fis.close();
    Result:
    If the file size is less than 32kb, it inserted successfully.
    but if more than 32kb, it throws follwing exception
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0352N An unsupported SQLTYPE was encountered in position "1" of the input list (SQLDA). SQLSTATE=56084
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
    at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.loadParameters(Unknown Source)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
    at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
    Can any body please help out to insert clob value.
    Thanks in advance
    V.Shan

    Normally I would be happy to help you, but after several years of trying to help here, I've decided not to contribute anymore because of the piss-poor way in which this site is being administered.
    Others are still helping, but more may leave if things don't improve. May I recommend devshed or javaranch?
    http://www.devshed.com/
    http://www.javaranch.com/
    If you would like to complain to the admins of this forum, either click the "Report Abuse" link or the "Feedback" link.
    -- foofoo (shamelessly stolen the text from jverd).

  • Java Code to Convert a file (license) in Excel's CVS Format

    Hi!
    Can anyone suggest me the Code to convert a File in a very specific format that we can read in Excel liek CVS Format of Excel?
    Thanks
    Bob

    What is the format of the License file? Is there a format like .licence format or something like that. Excel recognizes CSV's. So if you can expand the format of the incoming licence file, I may be able to help you.

Maybe you are looking for