How to convert given .text to .html

I need to convert a textfile content to a html output.
supppose if i gave Hello in a text file it should give me html file saying hello in browser

Just put the necessary html-tags around:            try {
                PrintWriter lv_out = new PrintWriter(new BufferedWriter(new FileWriter("filename.html")));
                lv_out.write("<html><body>\n");
                /* insert text-file */
                BufferedReader lv_in = new BufferedReader(new FileReader("filename.text"));
                String line;
                while ((line = lv_in.readLine()) != null)
                    lv_out.write(line + "\n");
                lv_in.close();
                lv_out.write("</body></html>");
                lv_out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }make a > out of every "?gt?" (this forum doesnt display correctly it sometimes).
koem

Similar Messages

  • How to convert plain text into html?

    Hi
    I'm looking for a nice method which converts any plain text to html. For example, text: "Me and you\nand a dog named boo."Conversion result should be:
    <html>
    <body>
    Me and you<br>
    and a dog named boo.
    </body>
    </html>I know, I could write such a code myself using regex. But I just wonder whether something like this already exists in the java api?
    Greetings from Switzerland
    Mickey

    Use a StringReader to read the lines and add the lines between <html><pre> ... </pre></html>

  • How do I mix text and Html format in a java mail?

    How do I mix text and Html format in a java mail? some part I want to keep the text format, the other part I want to use Html functions(like fond, color, etc)

    You don't mix them. Pick one or the other.
    However if you want to have a text version and an HTML version, so that mail readers that don't handle HTML can see regular text instead, then you could produce a "multipart/alternative" message. There's an explanation of how to do that in this article:
    http://www-128.ibm.com/developerworks/java/library/x-xmlist2/

  • How to convert table content into html format?

    Hi,
    Experts,
    How to convert internal data into HTML format is there any function module or piece of code to download content into HTML.
    Thank u,
    Shabeer Ahmed.

    Then use this code....
    REPORT  ytest_table_html1.
    *        D A T A   D E C L A R A T I O N
    *-HTML Table
    DATA:
      t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
                                           " Html Table
    *- Declare Internal table and Fieldcatalog
      it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
                                           " Flights Details
      it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
                                           " Fieldcatalog
    *-Variables
    DATA:
      v_lines TYPE i,
      v_field(40).
    *-Fieldsymbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *        S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
      SELECT *
        FROM sflight
        INTO TABLE it_flight
        UP TO 20 ROWS.
    *        E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *-Fill the Column headings and Properties
    * Field catalog is used to populate the Headings and Values of
    * The table cells dynamically
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'SFLIGHT'
        CHANGING
          ct_fieldcat            = it_fcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2.
      DELETE it_fcat WHERE fieldname = 'MANDT'.
      t_html-line = '<html>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<td><h1>Flights Details</h1></td>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '</thead>'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<table border = "1">'.
      APPEND t_html.
      CLEAR t_html.
      t_html-line = '<tr>'.
      APPEND t_html.
      CLEAR t_html.
    *-Populate HTML columns from Filedcatalog
      LOOP AT it_fcat.
        CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
            it_fcat-scrtext_l
            '</th>' INTO t_html-line.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</tr>'.
      APPEND t_html.
      CLEAR t_html.
      DESCRIBE TABLE it_fcat LINES v_lines.
    *-Populate HTML table from Internal table data
      LOOP AT it_flight.
        t_html-line = '<tr>'.
        APPEND t_html.
        CLEAR t_html.
    *-Populate entire row of HTML table Dynamically
    *-With the Help of Fieldcatalog.
        DO v_lines TIMES.
          READ TABLE it_fcat INDEX sy-index.
          CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
          ASSIGN (v_field) TO <fs>.
          t_html-line = '<td>'.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = <fs>.
          APPEND t_html.
          CLEAR t_html.
          t_html-line = '</td>'.
          APPEND t_html.
          CLEAR t_html.
          CLEAR v_field.
          UNASSIGN <fs>.
        ENDDO.
        t_html-line = '</tr>'.
        APPEND t_html.
        CLEAR t_html.
      ENDLOOP.
      t_html-line = '</table>'.
      APPEND t_html.
      CLEAR t_html.
    *-Download  the HTML into frontend
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'C:\Flights.htm'
        TABLES
          data_tab                = t_html
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *-Display the HTML file
      CALL METHOD cl_gui_frontend_services=>execute
        EXPORTING
          document               = 'C:\Flights.htm'
          operation              = 'OPEN'
        EXCEPTIONS
          cntl_error             = 1
          error_no_gui           = 2
          bad_parameter          = 3
          file_not_found         = 4
          path_not_found         = 5
          file_extension_unknown = 6
          error_execute_failed   = 7
          synchronous_failed     = 8
          not_supported_by_gui   = 9
          OTHERS                 = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    none of the above function modules r obsolete...

  • How to convert word documents to html page in sharepoint online 2013

    Hi,
    I am new SharePoint and still learning it.
    I have been tasked to do the following on office 365 E3 SharePoint 2013 Online edition.
    1) I have to create a Web page in asp.net
    2) This page needs to show document from a given SharePoint folder and bind them in a grid or dropdown on the asp .net web page
    3) On selecting the document from the drop down or gird (on asp .net webpage), I need to show the SharePoint word document as HTML on the webpage (something like word to html) Note: These SharePoint word document may contain Images, bullets, tables etc. 
    What I have been able to do till now
    1) I have been able to connect to SharePoint from ASP .net application.
    2) I have been able to retrieve document from a specific SharePoint folder.
    3) Read the document from SharePoint folder and bind them to a drop down on the asp .net page.
    What is missing?
    I am not aware about any API that SharePoint Online provides to convert Word document to HTML. Any code sample or reference on how to will be much appreciated. 
    I am not also not sure what is the best way of achieving the functionality this?
    Thanks 
    Krishna

    If this was SharePoint server then it would be easy however in O365 You need to create a app which will use the word automation service and below is  powershell which you can use for the conversion:-
    # This script will convert Docx to PDF using word automation and similarly it can be used to convert to HTML
    $wordFile="http://contoso/kick.docx"
    $pdfFile="http://contoso/kick.pdf"
    $wasp = Get-SPServiceApplicationProxy | where { $_.TypeName -eq "Word Automation Services Proxy" }
    $site = Get-SPSite "http://contoso"
    $ConvertJob = New-Object Microsoft.Office.Word.Server.Conversions.SyncConverter($wasp)
    $ConvertJob.UserToken = $site.UserToken
    $ConvertJob.Settings.UpdateFields = $false
    $ConvertJob.Settings.OutputFormat = "PDF"
    $ConvertJob.Convert($wordFile, $pdfFile)

  • How to convert a text file in lower case to upper case?

    I've a beginner in java world and I just come through the tutorial in http://java.sun.com/docs/books/tutorial/essential/io/filestreams.html showing how to copy a text file:
    import java.io.*;
    public class Copy {
    public static void main(String[] args) throws IOException {
         File inputFile = new File("farrago.txt");
         File outputFile = new File("outagain.txt");
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;
    while ((c = in.read()) != -1)
    out.write(c);
    in.close();
    out.close();
    And I would like to ask how to covert all lower case letters in input file to upper case letter in output file at the same time of copying.
    I guess it'll be using Character.toUpperCase(c), but I don't know how to do it actually.
    Any help would be much appreciated.

    Hope this helps
    import java.io.*;
    public class Copy {
    public static void main(String[] args) throws IOException {
    File inputFile = new File("farrago.txt");
    File outputFile = new File("outagain.txt");
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    BufferedReader buff = new BufferedReader(in);
    String c;
    while ((c = buff.readLine()) != null)
    out.write(c.toUpperCase());
    in.close();
    out.close();
    }

  • How to convert a "text variable" to String with plugin

    Hello,
    I am currently developing a InDesign (CS5) plugin, where I need to manipulate text variable.
    From the plugin I want to convert the "text variable" to string (in principle I should use the method "VariableToString (..)" of "ITextVariable")"
    My problem is, how to find the text varial from its name (I think I should use the method "FindLocationsUsed(..)" of "ITextVariableSuite") and then convert it to String
    I don't know how to use interfaces ITextVariable and ITextVariableSuite
    Plugin implemented in C++ language
    thank you

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

  • How to convert the TEXT file into an XML using plsql code

    Hi all ,
    I need to convert an TEXT file into an XML file how can i do it
    Below is my sample TEXT file .
    TDETL00000000020000000000000120131021115854ST2225SKU77598059          0023-000000010000
    I want the above to be converted into the below format
    <?xml version="1.0" encoding="UTF-8"?>
    <txt2xml>
      <!-- Processor splits text into lines -->
      <processor type="RegexDelimited">
      <regex>\n</regex>
            <!--
            This is used to specify that a message should be created per line in
            the incoming file;
            NOTE: this was designed to work with all the processors, however it
            only works correctly with 'RegexDelimited' processors (check the
            enclosing top processor type)
             -->
             <maxIterationsPerMsg>1</maxIterationsPerMsg>
      <!-- For lines beginning with FHEAD (File Header) -->
      <processor type="RegexMatch">
      <element>FHEAD</element>
      <regex>^FHEAD(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,Type,Date</element>
      <regex>^(\d{10})(\w{4})(\d{14})$</regex>
      </processor>
      </processor>
      <!-- For lines beginning with TDETL (Transaction Details) -->
      <processor type="RegexMatch">
      <element>TDETL</element>
      <regex>^TDETL(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,TransControlNumber,TransDate,LocationType,Location,ItemType,Item,UPCSupplement,InventoryStatus,AdjustReason,AdjustSign,AdjustQty</element>
      <regex>^(\d{10})(\d{14})(\d{14})(\w{2})(\d{4})(\w{3})([\w ]{13})([\w ]{5})(\d{2})(\d{2})([+-]{1})(\d{12})$</regex>
      </processor>
      </processor>
      <!-- For lines beginning with FTAIL (File Tail) -->
      <processor type="RegexMatch">
      <element>FTAIL</element>
      <regex>^FTAIL(.*)</regex>
      <processor type="RegexMatch">
      <element>OriginalLine</element>
      <regex>(.*)</regex>
      <consumeMatchedChars>false</consumeMatchedChars>
      </processor>
      <processor type="RegexMatch">
      <element>LineSeq,TransCount</element>
      <regex>^(\d{10})(\d{6})$</regex>
      </processor>
      </processor>
      </processor>
    </txt2xml>
    Thanks

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • How to convert CSV/Text files to XML format

    Hi,
    I am trying to convert a .csv/.txt(Flat) file(s) to XML format. How can i achive this?
    Ex: I want to convert this text file to XML.
    Book#      first name                                last name                               ID#                 ID1#      F#
    B99          FRISBY                                  NASIER                                  LUCJ A         A 3127      1    
    B131         HAWKINS                              MICHAEL                               LUCJ A         A 3129       2    
    B313         KING                                     JOSHUA                                 CUCJ I         I-DORM      10   
    B307         GRAVES                               KIMBERLY                              NUCJ F         F-DORM     24-FL
    R469         HEATH                                  DARRELL                                SUCJ A         A 3132       1    
    R212         PEREZ                                  DARRELL                                SUCJ A         A 3133       2    
    R62          COFFEY                                GREGORY                               NUCJ HC      H C 3112    3FLOOR
    R215         BLACKWELL                          DEREK                                   LUCJ OOW     W 01       1     Could anyone please suggest me if we have any open source java api to acheive this?
    Thanks,
    Srikanth.

    Have a look at [http://servingxml.sourceforge.net/|http://servingxml.sourceforge.net/] or [http://www.talend.com/|http://www.talend.com/]

  • How to convert the text field into currency field

    Hi,
    I have an requirement to converting the text field into currency.
    If I convert directly it gives dump.
    If I convert this to Numeric means it takes the decimals also as whole value.
    Is there any FM to convert the text field into Currency field.
    Please advice me.
    Thanks in advance.

    Hi,
    I am on an SRM sytem, which unfortunately does not have th FM: PSSV_TEXT_INTO_FIELD_CURRENCY.
    But I also need to transfer a string value like '12,99' to a field with type curr.
    Can i Do that manually, or is there another FM?
    I have already checked code with write to or pack/unpack.
    But without success yet.
    Something like this:
    DATA: g_str(11) type c.
    DATA: g_p type p.
    WRITE '12,99' TO g_str CURRENCY 'EUR'.
    is no use for me. Finally I need to move g_str to my curr-field, which causes st22.
    also: PACK g_str to <curr-field or g_p> dumps.
    Help appreciated.
    regards, matthias

  • How to convert simple text to image

    Hi,
    I needed to secure web form from automated form submission. Looking into some common website, they use image displaying random text, which is only readable by user. So the automated form submission can be avoided.
    I checked through lot of forum, but could not find help in doing it using java. So is there something in java api using which i can generate image of fly for each request by passing some random generated text of about 5-6 character length.
    Any help on this would be appreciated...
    Thanks,
    Naresh

    hi ican convert image ti html
    coding---------------
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.awt.event.*;
    public class img2html extends Frame
         static Image im=null;
         static int W=-1,H=-1;
         public img2html()     {}
         public static void main(String args[])
              String infile,outfile;
              infile="c:\\micky.jpg";
              outfile="c:\\micky.html";
              boolean paramsOK=false,mode=false;
              //if (args.length <= 1) {
              //     usage();
              //     paramsOK=false;
         //     if (args.length == 2) {
              //     infile = args[0];
              //     outfile = args[1];
                   paramsOK=true;
              if (paramsOK) {
                   //System.out.println("img2html :");
                   System.out.println(" image file " + infile);
                   System.out.println(" data file " + outfile);
                   img2html widow = new img2html();
                   System.out.println("img2html : Loading image file");
                   if (widow.processFile(infile)==false) {
                        System.exit(0);
                   //System.out.println("img2html : Saving data file");
                   saveByteData(outfile,mode);
                   System.exit(0);
         public static void saveByteData(String fn,boolean i)
              int[] grabMapXY;
              grabMapXY          =      new int[(W * H)];
              int pix;
              PixelGrabber pg = new PixelGrabber(im,0,0,W,H,grabMapXY,0,W);                
    //     PixelGrabber pg =
    // new PixelGrabber(image, 0, 0, -1, -1, false);
              // start grab
              try {
                   pg.grabPixels();
              } catch (InterruptedException e) {
                   System.out.println("Map grab failed : " + e);
                   return;
              if ((pg.status() & ImageObserver.ABORT) != 0) {
                   System.out.println("Map grab failed !");
                   return;
              // need to base r on number of valid pixels
              writeToFn(fn,"<HTML>");
              writeToFn(fn,"");
              writeToFn(fn,"<BODY>");
              writeToFn(fn,"");
              writeToFn(fn,"<TABLE border=0 cellspacing=0 cellpadding=0>");
              int red,green,blue,p;
              String r,g,b;
              Color c;
              for (int y =0; y < H; y++) {     
                   writeToFn(fn," <TR>");
                   for (int x =0; x < W; x++) {
                        pix=grabMapXY[ y * W + x ];
                        c = new Color(pix);
                        red=c.getRed();
                        blue=c.getBlue();
                        green=c.getGreen();
                        r=Integer.toHexString(red);
                        g=Integer.toHexString(green);
                        b=Integer.toHexString(blue);
                        if (r.length()==1) { r="0"+r; }
                        if (g.length()==1) { g="0"+g; }
                        if (b.length()==1) { b="0"+b; }
                        writeToFn(fn," <TD WIDTH=1 HEIGHT=1 BGCOLOR=#" + r + g + b + ">", " " + x + "," + y + " - of - " + W + "," + H);
                        writeToFn(fn," </TD>");
                   writeToFn(fn," </TR>");
              writeToFn(fn,"");
              writeToFn(fn,"</TABLE>");
              writeToFn(fn,"");
              writeToFn(fn,"</BODY>");
              writeToFn(fn,"</HTML>");
         public static void writeToFn(String fn,String Dbytes,String status) {
              try {
                   //System.out.println(Dbytes + " pixel " + status);
                   DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true));
                   dos.writeBytes(Dbytes); //
                   dos.writeByte(13); // line feed for each line
              dos.writeByte(10); // line feed for each line
                   // close here
                   dos.close();
              } catch (IOException e) {
                   System.err.println("File error: " + e.getMessage());
         public static void writeToFn(String fn,String Dbytes) {
              try {
                   //System.out.println(Dbytes );
                   DataOutputStream dos = new DataOutputStream( new FileOutputStream(fn,true));
                   dos.writeBytes(Dbytes); //
                   dos.writeByte(13); // line feed for each line
              dos.writeByte(10); // line feed for each line
                   // close here
                   dos.close();
              } catch (IOException e) {
                   System.err.println("File error: " + e.getMessage());
         public boolean processFile(String fn)
              boolean OK=false;
              int exitcounter;
              try {
                   im = getToolkit().getImage(fn);
              catch (Exception e)
                   System.out.println("1HOLY MOLY THIS NEVER HAPPENS!!!! "+e);
              MediaTracker tracker= new MediaTracker(this);
              tracker.addImage(im,0);
              try {
                   tracker.waitForID(0);
              catch (InterruptedException e)
                   System.out.println("2HOLY MOLY THIS NEVER HAPPENS "+e);
              if (tracker.isErrorID(0)) {
                   System.out.println("IMAGE FILE COULD NOT BE LOADED");
                   System.out.println(fn);
              } else {
                   exitcounter=0;
                   while ( ((W==-1)||(H==-1)) && (exitcounter<=16000000) )
                        W=im.getWidth(null);
                        H=im.getHeight(null);
                        exitcounter++;
                   if (exitcounter>15999999)
                        System.out.println("Timeout attempting to load image, is it to big?");
                   else
                        OK=true;
              return(OK);
         public static void usage() {
              //System.out.println("Usage:");
              //System.out.println("java img2html infile outfile ");
              //System.out.println(" infile : image file .gif ");
              //System.out.println(" outfile : html file to be created");
              //System.out.println(" /i : Inverse data ");
    }     // end of class

  • How to convert a text file content to String in JSP?

    Hi,
    I need to read the content of a text file and convert it into String and display it on to a JSP file.
    But the codings below don't work. Please advise me on how can i display the text file content.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    File adCheck = new File("list.txt");
    fis = new FileInputStream(adCheck);
    int Length = adCheck.length();
    byte arr[] = new byte[Length];
    int dataRead = 0;
    int totalData = 0;
    while(totalData <Length)
         dataRead = fis.read(arr,totalData,Length);
         totalData += dataRead;
    String Content = new String(arr);//byte array converted to String
    arr = null;

         InputStreamReader in=new InputStreamReader(fis);
          StringWriter out=new StringWriter();
          char[] buffer=new char[8192];
          int sizeRead;
          while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
            out.write(buffer, 0, sizeRead);
         String content=out.toString();

  • How do i decode text to html text

    Hi All,
    My question is very simple, i want to convert text that i get to html string format in AS3, for example:
    if i have the variable:
    var textString:String = "< this is str >";
    if need a way to convert it to: "&gt this is str&lt" and store is into a string in this format
    Any ideas?

    That's something that you'd most likely do on the server side, and not in Flex, you could do it in Flex using Regex patterns and replacing the characters manually.

  • How to convert oracle report in html form into excel form?

    Hi friends !! I m trying to convert oracle 10g report into excel form.Its coming in excel form but not with all formats.How to solve the problem?

    Hello,
    Please give us more information what kind of report(s). Sample example etc.,
    Sri

  • How to Convert Standard Text in Smart forms?

    Hello Friends,
               My requirement is to display the lables in Chinese Language. Those text elements should be displayed in Chinese Format. How can we do it. Is there any way to display text in Chinese format. please help me out from this senario.
    Thanks & Regards
    Sathish Kumar

    Hi,
        IF you have labels in chinese format then do transilation.
    1. Go to se63.
    2. Transilation -->R/3 Enterprise -->Other Long texts
    3. click on FS-->SSF.
    4. Give your smartform name
    5. Source langue -- EN and Target Language ZH
    6. English language text will be in display mode.. In change mode change them into chinese format.
    7. Save
    8.Activate transilation done and your smartforms also.
    Br,
    Laxmi

Maybe you are looking for