This question already has answers here:
How to read and write XML files?
(6 answers)
Closed 7 years ago.
We need to write XML files to a zip file. This part of our code is 22%+ of the total processing time so optimizing this will be a big win. We're presently using dom4j to write out to a Document and then using XMLWriter to write the generated Document to the ZipOutputStream.
We need to run on Java 1.4.
The code is written so we do NOT need a DOM. We walk through writing the xml in order so if it can then write immediately to the zip stream, that would work well.
Update: We also use dom4j for XPath queries (where we do read the XML into a DOM). We can have 2 libraries but if there's an alternative that is better for both uses, that would be good too.
But for this specific need, it's pure write it out, in order (ie no DOM needed).
I think StAX produces streamed XML Output: http://stax.codehaus.org/. That would get you out of maintain a DOM in memory for the output XML.
Related
I have checked multiple links and two options were shown for editing MS visio file in Java code.
Apache POI - HDGF and XDGF - Java API To Access Microsoft Visio Format Files
Aspose.diagram APIs
Has anyone done any coding in Java language using above option?
I am using eclipse IDE.
Also please suggest if there is third better way to edit MS visio file using java code.
If you are talking about libraries, these are the two basically. Apache POI AFAIK can't create diagrams, only read, if I am not mistaking - but please verify, maybe something changed since I last looked at that ten years ago.
So this basically leaves you with a single choice. Or you can always spend a few years and write it all yourself. Well, man does not simply walk into mordor create visio files with java.
Maybe you could consider using SVG instead, that can be generated and consumed by basically anything? Visio can also read and write SVG out of the box.
This question already has answers here:
How to read and write excel file
(22 answers)
Closed 6 years ago.
could you please anyone assist me how to read excel files datas and write into csv file using java????
Please give Code for this scenario
Thanks in Advance
Regards
Kumar
One simple solution would be to convert your excel file into a .CSV file by saving it as such. Then you could, depending on the excel table structure, read the CSV file if the table successfully saved as one.
I think reading a simple CSV-file in Java won't require any sample-coding from me since it is fairly simple if one understands the I/O operations of the Java API.
If you actually need to do that converting manually I would not go for Java here. Use VBA which is used for macro programming in Excel.
I'm using SWI-Prolog with the JPL library.
I have a program written in Java that produces strings like these:
fact(1,2)
fact(2,3)
fact(1,3)
Then, there is a prolog file that needs this facts in the head of file.
I do not want neither insert the code in the head of file, nor use a text file, but only java.
Is there a solution for this?
If I'm reading this correctly, you need to write Strings into a Prolog file from Java?
Java can write into many files types including .txt, .word, and html. You can attempt to write to a Prolog file by using the extension name.
FileWriter exampleFileWriter = new FileWriter("exampleProlog.pl");
Just write the Strings, then close the file. There are many safer and better ways to writing to files in Java. Just look at this:
Fastest way to write to file?
http://www.javapractices.com/topic/TopicAction.do?Id=42
EDIT: This might be of help:
How use Prolog from Java?
I might have to make some Java classes that dynamically create strings with HTML tags. I remember years ago there was a third party library that wrapped such things nicely, ie html.tableopen() instead of writing an HTMl table tag. Is there such a library that is part of standard Java distributions, now? If not is there a free (as in open source )library or a better to make HTML strings in Java?
The latest one I know is
http://rendersnake.org/examples.html
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Parsing CSV in java
How to do I parse a csv file correctly in java? There are cases where simple StringTokenizer doesn't work as in the example below:
xxx,"hello, this breaks you"
Try using a dedicated library for that, e.g.:
http://opencsv.sourceforge.net/
JSaPar is another library that will do the work for you. You can find a comprehensive list of other alternative libraries here.
ostermiller.org has a jar with nice utility-classes like CSV-Parser/Writer etc.
Java Data File Read/Write Utility is a very straight forward and easy to use library for reading/writing CSV files.
Most important class's documentation - DataFile
Download
BeanIO can be used to bind CSV records to Java bean objects. Visit http://beanio.org for details.