How can I use Java to programmatically convert the internal stylesheet of a web page to an inline one?

Is there a ready-made tool or utility that already does this

-1


source to share


1 answer


You can just open the CSS file and just paste its content into the style tag.

It shouldn't be that hard:

FileReader frCSS = new FileReader("your_css.css");
FileReader frHTML = new FileReader("your_html.html");
FileWriter output = new FileWriter("result.html");

      



Then parse the frHTML and copy its content for output until you find the chapter opening tag. When you have done that, open the style tag and copy all the content from frCSS. Then close the style tag and copy the rest of the frHTML.

It's not pretty, but it can be done.

+1


source







All Articles