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........
Similar Messages
-
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] -
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 -
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,
VeeraYou can have a look at [http://sourceforge.net/projects/light-html2xml|http://sourceforge.net/projects/light-html2xml]
-
Editing html files using Contribute
I have just purchased the tracking software ProspectFinder
from Enecto.com that lets me see the names and details of the
companies visiting our website.
In order for the tracking to function, I need to paste some
lines of html code to the respective pages of my website whose
visitors I want to track.
How do I do that using Contribute?You can use Insert-> HTML Snippet... to do the same.
If this is disabled for your role, please administer the site
and edit your role setting. Select Editing in the Edit ROLE setting
dialog and check the option "Allow HTML Snippet
Insertion...". -
I want to Edit PDF file using java(urgent)
if any body helps me i shall be thankful to him.
its urgent i hav to complete my assignment.http://www.geocities.com/marcoschmidt.geo/java-libraries-pdf.html
http://www.firehouseinternational.com/usersite/uniforms/uniformsproduct.asp?categoryid=8787&productid=13454&page=1 -
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 create and edit a .ini file using java
Hi All...
Pls help me in creating and editing an .ini file using java...
thanks in advance
Regards,
sathyaLet's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class Test {
private static Properties props;
public static void main(String[] args) throws IOException {
File file = new File("test.ini");//This is out ini file
props = new Properties();//Create the properties object
read(file);//Read the ini file
//Once we've populated the Properties object. set/add a property using the setProperty() method.
props.setProperty("testing", "value");
write(file);//Write to ini file
public static void read(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
props.load(fis);//load the ini to the Properties file
fis.close();//close
public static void write(File file) throws IOException {
FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
props.store(fos, "");//write the Properties object values to our ini file
fos.close();//close
} -
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). -
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
yafisMaybe 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);
} -
Hi,
I downloaded an html file from our server to edit the logo. However, I am unable to edit the logo part. It's like commented out. And once I opened the file on Dreamweaver CS5, I am getting this pop-up message:
"This page contains some SWF objects that may not work properly in the most recent versions of Internet Explorer. Dreamweaver cannot convert them to the new SWF markups. Please delete each of them and insert again."
I can't edit the html file and change the logo. Please help.
Thank you and God bless!
DannieDannie,
Are you familiar with dreamweaver templates and editable regions? If the logo is in the template, then you need to modify the template file. The changes you make to the template will automatically be propogated to all of the files which use the template. If your html file uses a template, the html code will look like its commented out.
Also, you should not have to download the html fiile from your server because you should always keep a copy of all the html files on your computer.
I don't know about the SWF error.
Good luck.
mitzy_kitty -
Create crystal report file using JAVA
Can someone tell me how to a Create crystal report file using JAVA Programming
I want a very simple examplePlease help me. It's urgent.[http://catb.org/~esr/faqs/smart-questions.html#urgent]
Be back in an hour or two... -
Can't edit .html file in dreamweaver?
Why can't I edit .html file in Dreamweaver CS 5.5 when it is not attached to a template?
I have always been able to edit it every other time I have opened the file (since I built the site over two years ago).
Now each time I try to edit it in Design mode, no matter where I click in the file the whole page gets a dark grey overlay and I can't get a curser.
I am still able to edit the code directly but I do not want to be restricted.
The last thing I did the last time I opened the file was paste Google Analytics code in just before the </head> tag. I did this to all the files on the site but this is the only one that isn't working. I have tried taking out this code but it makes no difference.
I am using a 6 month old Macbook pro.
Can anyone help me?In your stylesheet you have -
.container { overflow:hidden; width: 100%;}
.container2 { overflow:hidden; width: 646px; margin:0 0 10px 0}
Try right clicking on the page in Design view and then selecting Element view > Full and see if that helps. -
How to create hyperlink in Html page using Java
Hello every one
I want to know that how can I create a hyperlink in Html page using java ?
Let for example
I have code like this and i want to give hyperlink to it using java.
rember that i am creating node using this id="name" which give me multiple value. and i want to assign diff link to each name..?
<tr>
<td ><span id="name"></span>
</tr>but i m using this code to create node in html file
HTMLLIElement li = (HTMLLIElement)appHTML.createElement("LI");
Text txt = appHTML.createTextNode(name);
li.appendChild(txt);
appHTML.getElementById("name").appendChild(li);
this will display all name value which is coming from database,
and i want to assign a hyperlink to it,
I have id with name also so I thought that using id i will
create javascript like
function popup(id)
if(id==1)
var n1 = window.open("../list/name1.html");
if(id==2)
var n1 = window.open("../list/name2.html");
this way i want to popup particular file if i can pass id value in this function
so want hyperlink like
name -
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,
Sam1. 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
Maybe you are looking for
-
Please ignore my previous Thread. Where do you get the nessecary libaries to compile servlets, and what directory of the JSDK1.4.0/ directory do you put them in (Im using Win98se)
-
IOS 8 reminders stuck with geofence
After updating to iOS 8 and creating one reminder with a geofence and then marking it done, the location services icon at the top of my iPhone 5 is now showing all the time (the outline icon). I've gone into Location Services and turned each item off
-
OMW hangs on mapping some databases
Hello: I am migrating about 20 databases from MS SQL 6.5 to Oracle 8.0.5. 15 of the databased migrate flawlessly, but 5 of them hang on OMW during the mapping phase. I have to "End Task" the program to get it to stop. I have played with the source mo
-
Aides Photoshop CC et Lightroom inaccessibles
Bonjour, J'ai acheté hier Photoshop CC et Lightroom que j'ai installés en français (avec également Bridge) sur 2 PC sous Windows 7 (un en français et l'autre en anglais). Toutes les applications fonctionnent correctement mais l'aide en ligne de Photo
-
My ipad mini keeps on crashing when i play games (eversince i updated it)...can anybody tell me what i need to do to prevent this?