I-text for saving html files using java

hi,
i'm writng a small application and it has some report generation part based on some html templates.
These templates have some images which are given the relative path in the html template files.
when i generate my reports they generated and save in some other location and the thing is quite naturally all the image files are missing. can anyone help me to overcome this problem??
thanks in advance.

If you are using Windows take a look at what Internet explorer does when you save a web page
If the files is save as MyFile.htm the browser will create a folder called MyFile_Files and store all the images there. and it will modify the code of the html file to refer those images.
I think that you will have to do the same.
Or
Find some API which can convert HTML page in to PDF and save PDF then you will get a one file with everything in it. I think that is a better solution.
But the way If you found such an API dont foget to post here about it . I have the same problem and I dont like the solution one

Similar Messages

  • Pls Help--- URGENT... Combining XML file and HTML file Using java program.

    Hi, I need to implemnt this for my project....
    I need to combine XML and HTML file and generate a new HTML file
    Sample XML File:
    <user>
    <txtName>sun</txtName>
    <txtAge>21 </txtAge>
    </user>
    Sample HTML File:
    <body>
    Name: <input type="text" name="txtName" value=""
    Age : <input type="text" Age="txtAge" value=""
    </body>
    I need a java program to combine the above xml and html files and generate the output in HTML.
    Any kind of help is sincerely Appreciated.
    Thanks.

    toucansam wrote:
    So you want us to write it for you? It's pretty straight forward, first parse the xml file with the *[best java xml parser|http://www.google.com/search?&q=parsing+xml+in+java]* and then go through the nodes and construct the html with strings and concatination. Then write the file using *[the best java file writer|http://www.google.com/search?hl=en&q=writing+to+a+file+in+java]*.
    He would do better to use existing tools that make this easy [http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html|http://www.ling.helsinki.fi/kit/2004k/ctl257/JavaXSLT/Ch05.html]

  • Edit HTML File using java

    Hi....
    I have a report in HTML format and a list of thresholds in txt format.
    Now, using java how can I:
    1. Compare the values in the report with the thresholds
    2. Edit the report such that values over the thresholds are highlighted in say, red colour.
    I am new to Java programming, so java jargons won't be of much help. I read about jeditorpane but it's primary use is to display html file(that is what i inferred). Is their a way in which i could accomplish the above using jeditorpane??....how do i do the comparison part??

    srgsoroka wrote:
    Did you check http://jtidy.sourceforge.net/.
    From site:
    "JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML."Yes, I did. But I don't need a syntax checker.The syntax is alright. I want to modify the HTML code after comparison with a txt document.As far as DOM parser is concerned, I googled the term but didn't understand much of it..:-(...If you could explain it in layman's terms........

  • Convert XML File from HTML file using java

    Hi All,
    I am trying to convert HTML file into XML file.
    But, Unfortunatelly didnt get the exact result.
    If anyone have a sample code please share with me.
    Any suggestions greatly appreciated.
    Thanks,
    Veera

    You can have a look at [http://sourceforge.net/projects/light-html2xml|http://sourceforge.net/projects/light-html2xml]

  • Interchage html table using java

    hey all ,
    how can i interchange the row and column of the table which is written inside a HTML file using Java ?
    like if i have html input file like :
    <HTML>
    <BODY>
    <table border="1">
    <tr>
    <th>NAME</th>
    <th>MONDAY</th>
    <th>TUESDAY</th>
    <th>WEDNESDAY</th>
    </tr>
    <tr>
    <td>A</td>
    <td>C++</td>
    <td>C</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>B</td>
    <td>C</td>
    <td>C++</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>C</td>
    <td>Java</td>
    <td>C++</td>
    <td>C</td>
    </tr>
    </table>
    </BODY>
    </HTML> then my java program generate HTML output file like this :
    <HTML>
    <BODY>
    <table border="1">
    <tr>
    <th>NAME</th>
    <th>A</th>
    <th>B</th>
    <th>C</th>
    </tr>
    <tr>
    <td>MONDAY</td>
    <td>C++</td>
    <td>C</td>
    <td>Java</td>
    </tr>
    <tr>
    <td>TUESDAY</td>
    <td>C</td>
    <td>C++</td>
    <td>C++</td>
    </tr>
    <tr>
    <td>WEDNESDAY</td>
    <td>Java</td>
    <td>Java</td>
    <td>C</td>
    </tr>
    </table>
    </BODY>
    </HTML>

    hi all ,
    check out this code wiz , but it will not work when when the 2d string array is not square matrix ...any suggestions to remove this limitation ?
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.*;
    public class ParseHTML
         public static void main(String[] args)
              String a[][]=new String[10][10];
              String fName = "test.html"; //input file name
              a=htmlread(fName);
              String b[][]=new String [10][10];
              b=transpose(a);
              htmlwrite(b,fName);
         public static String[][] htmlread(String fName) //this method will read the file and returns a matrix
              String thisLine;
                  String temp[][]=new String[10][10];
                  try
                  FileInputStream fis = new FileInputStream(fName);
                  DataInputStream myInput = new DataInputStream(fis);
                  int i=-1;
                  int j=-1;
                  while ((thisLine = myInput.readLine()) != null)
                   if(thisLine.trim().startsWith("<tr>"))
                        i++;
                        j=-1;
                   if(thisLine.trim().startsWith("<td>"))
                        j++;
                        thisLine=thisLine.replace("<td>","");
                        thisLine=thisLine.replace("</td>","");
                        temp[i][j]=thisLine;
            catch(IOException e)
                   e.printStackTrace();
                   System.out.println("File Not Found");
            return temp;
        public static String[][] transpose(String a[][]) //this method will return a tranpose matrix
             String b[][]=new String[a[0].length][a.length];
             for(int i=0;i<a[0].length;i++)
                  for(int j=0;j<a.length;j++)
                       b[i][j]=a[j];
         return b;
    public static void htmlwrite(String b[][],String fName)
    FileOutputStream fout;
    int i=-1;
    int j=-1;
    int flag=0;     
                   // Open an output stream
              try
              fout = new FileOutputStream ("myfile1.html");     
                   FileInputStream fis = new FileInputStream(fName);
              DataInputStream myInput = new DataInputStream(fis);
              String thisLine;
              while ((thisLine = myInput.readLine()) != null)
                   if(thisLine.trim().startsWith("<tr>"))
                        i++;
                        flag=0;
                   if(thisLine.trim().startsWith("<td>"))
                        j++;
                        if(flag==0)
                             j=0;
                             flag=1;
                        thisLine="<td>"+b[i][j]+"</td>";
                        System.out.println(i+" "+j);
              // Print a line of text
              new PrintStream(fout).println (thisLine);
              // Close our output stream
              fout.close();
              catch (IOException e)
                   System.err.println ("Unable to write to file");
                   System.exit(-1);

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • 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...

  • Changing HTML to text file using java

    Hi,
    I am doing a project in which i have to read news articles from websites. I have tried XML but for that i need to know which tag has the article in it. Since i have to read from various websites so each site used different tags for different informations.
    Is there anyway that i can change an HTML file into a text file using java. Maybe some command that removes all the HTML tags and gives just the information. Is there anything else that anyone would like to recommend?
    Thanx
    yafis

    Maybe something like this:
    import java.io.*;
    import java.net.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    class GetHTMLText
         public static void main(String[] args)
              throws Exception
              EditorKit kit = new HTMLEditorKit();
              Document doc = kit.createDefaultDocument();
              // The Document class does not yet handle charset's properly.
              doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
              // Create a reader on the HTML content.
              Reader rd = getReader(args[0]);
              // Parse the HTML.
              kit.read(rd, doc, 0);
              //  The HTML text is now stored in the document
              System.out.println( doc.getText(0, doc.getLength()) );
         // Returns a reader on the HTML data. If 'uri' begins
         // with "http:", it's treated as a URL; otherwise,
         // it's assumed to be a local filename.
         static Reader getReader(String uri)
              throws IOException
              // Retrieve from Internet.
              if (uri.startsWith("http:"))
                   URLConnection conn = new URL(uri).openConnection();
                   return new InputStreamReader(conn.getInputStream());
              // Retrieve from file.
              else
                   return new FileReader(uri);
    }

  • How to read a text/html file in java regardless of its encoding?

    Hi All,
    How to read a text/html file in java regardless of its encoding?
    1. Is there any way to identify that a file (read using FileInputStream/or any other means with java.io package) has been saved with which type of encoding i.e. whether the file is using ANSI encoding or Unicode encoding or other?
    2. Is there any standard way to read an encoded file (i.e. files having UTF-16 format for Asian locales character support) and un-encoded file (i.e. files having ordinary ANSI format) correctly without knowing the user input?
    The problem is that while creating an instance of 'InputStreamReader' (ISR) we can pass the encoding type used (otherwise it takes the system's default encoding type), and the ISR expects the file to be in the same encoding format otherwise it reads it as some junk. But we don't know which file the user is going to pass whether it is Unicode (for Asian locales file should be in Unicode) with or ANSI coded (for non-Asian / English locales user generally uses ANSI encoding).
    Regards,
    Sam

    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

  • 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

  • Read Text file using Java Script

    Hi,
    I am trying to read a text file using Java Script within the webroot of MII as .HTML file. I have provided the path as below but where I am not able to open the file. Any clue to provide the relative path or any changes required on the below path ?
    var FileOpener = new ActiveXObject("Scripting.FileSystemObject");
    var FilePointer = FileOpener.OpenTextFile("E:\\usr\\sap\\MID\\J00\\j2ee\\cluster\\apps\\sap.com\\xapps~xmii~ear\\servlet_jsp\\XMII\\root\\CM\\OCTAL\\TestTV\\Test.txt", 1, true);
    FileContents = FilePointer.ReadAll(); // we can use FilePointer.ReadAll() to read all the lines
    The Error Log shows as :
    Path not found
    Regards,
    Mohamed

    Hi Mohamed,
    I tried above code after importing JQuery Library through script Tag. It worked for me . Pls check.
    Note : You can place Jquery1.xx.xx.js file in the same folder where you saved this IRPT/HTML file.
    <HTML>
    <HEAD>
        <TITLE>Your Title Here</TITLE>
        <SCRIPT type="text/javascript" src="jquery-1.9.1.js"></SCRIPT>
        <script language="javascript">
    function Read()
    $.get( "http://ldcimfb.wdf.sap.corp:50100/XMII/CM/Regression_15.0/CrossTab.txt", function( data ) {
      $(".result").html(data);
      alert(data);
    // The file content is available in this variable "data"
    </script>
    </HEAD>
    <BODY onLoad="Read()">
    </BODY>
    </HTML>

  • How to print a text file using Java

    How can I print a text file using Java without converting the output to an image format. Is there anyway I can send the characters in the text file as it is for a print job? I did get a listing doing this ... but that converted the text to an image format before printing....
    THanks,.

    Hi I had to write a print api from scratch, and I did not convert the output to image. Go and read up on the following code. I know there is a Tutorial on Sun about the differant sections of the snippet.
    private void printReport()
         Frame tempFrame = new Frame(getName());
         PrintJob printerJob = Toolkit.getDefaultToolkit().getPrintJob(tempFrame, "Liesltext", null);
         Graphics g = printerJob.getGraphics();
                    //I wrote the method below for calculations
         printBasics(g);
         g.dispose();
         printerJob.end();
    }This alone wont print it you have to do all the calculations in the printBasics method. And as I said I wrote this from scratch and all I did was research first the tutorial and the white papers
    Ciao

  • How do i search for a string in a txt file using java??

    How do i search for a string in a txt file using java??
    could you please help thanks
    J

    Regular expressinos work just fine, especially when
    searching for patterns. But they seem to be impying
    it's a specific group of characters they're looking
    for, and indexOf() is much faster than a regex.If he's reading from a file, the I/O time will likely swamp any performance hit that regex introduces. I think contains() (or indexOf() if he's not on 5.0 yet) is preferable to regex just because it's simpler. (And in the case of contains(), the name makes for a very clear, direct mapping between your intent and the code that realizes it.)

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • 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

Maybe you are looking for