I want to display a regular XML or any other file in text format in JEditorPane..I don't want to display the content in html page... the content should be exactly the same as in file with line break..the XML file is located on local system
Do you need syntax highlighting?
or just show plain text?
If syntax try to use this
http://java-sl.com/xml_editor_kit.html
If not just use JTextArea or normal JEditorPane with default editor kit. And call setText() to set your content.
Related
I have following link
https://hero.epa.gov/hero/ws/swift.cfc?method=getProjectRIS&project_id=993&getallabstracts=true
I want to parse this xml to get only text, like
Provider: HERO - 2.xx
DBvendor=EPA
Text-encoding=UTF-8
How can I parse it ?
Well, it's not a text file, it's an HTML file. If you open a file in browser and select view source you will be able to see text enclosed in <char> tags.
When it's opened in browser, these tags and other HTML content is interpreted and output is rendered on the page (that's why it looks like a text). If you want to implement similar behavior in Java then you should look into PhantomJS and/or JSoup examples.
It looks like a text file but it is an XML file and the browser just displays its text content.
To verify right click and look at the page source.
You can use a library like Jsoup for parsing the file and getting the contents.
https://jsoup.org/cookbook/introduction/parsing-a-document
I was wondering if there's a way to load an HTML file on JavaFx's HTMLEditor but rather then loading it as a web page, show the actual raw source code on the HTMLEditor. Is this possible with JavaFX's HTMLEditor?
I tried the following:
File f = fc.showOpenDialog(null); //This allows a user to find a file in a dialog
String textRead = readFile(f); //store the files content in a string
htmlFileEditor.setHtmlText(textRead); //displays the source but not as raw HTML
This only loads the html file and displays it, Im wondering if there is a way to show the raw source code of the HTML file loaded with tags and all on the HTMLEditor.
Hyperlink in content of CSV file works but style is not appearing on link. I have a .csv file that I was able to put in a hyperlink. When it opens in excel and put your cursor across the cell it shows the little hand and when click will open the hyperlinked document.
I have used Java Program to create a CSV file. My Code for hyperlink looks like:
hyperlink = "=HYPERLINK(\"http://stackoverflow.com\")";
What I would like to do is make that blue and underline?
Csv file does not support a format to append like styles
The only way is that we can use hyperlink in csv file
Lets see at this example:
I've got HTML tagged text:
<font size="100">Example text</font>
I have *.odt (OpenDocument Text) document where I want to place this HTML text with formatting depends on HTML tags (in this example font tag should be ommited and text Example text should have 100point size font in result *.odt file).
I prefer (but this is not strong requirement) to use OpenOffice UNO API for Java to achieve that. Is there any way to inject this HTML text into body of *.odt document with simple UNO API build-in HTML-odt converter or something like this (or I have to manually go through HTML tags in text and then use OO UNO API for placing text with specific formatting - e.g. font size)?
OK, this is what I've done to achieve this (using OpenOffice UNO Api with JAVA):
Load odt document where we want to place HTML text.
Goto place where you want to place HTML text.
Save HTML text in temp file in the system (maybe it is possible without saving with http URL but I wasn't testing it).
Insert HTML into odt following this instructions and passing URL to temp HTML file (remember about converting system path to OO path).
Maybe you can use JODConverter or you can use the xslt from xhtml2odt
I need to print a an html out to the printer programmatically. I do not want to print the html tags, I want the html tags parsed before printed.
This code adds html features and data to an htm document named document. I am then sending the output to a file named itext.html
HtmlWriter writer2 = HtmlWriter.getInstance(document,new FileOutputStream("itext.html"));
I know need to somehow parse that html file and print it without having to open it up in a browser and going to FILE and Print.
Cobra will render HTML to a Swing-compatible panel. You should be able to print that using the standard Print APIs/services.