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.
Related
I am trying to read a .pdf file the same way you read a .txt file. I need to parse the pdf file to obtain some information.
Refering to this Stack Exchange article
(Your question is probably a duplicate)
How to read PDF files using Java?
Use a library like Apache's PDFBox to do it.
Please do some basic research next time before you ask a question, I found tons of answers in about three minutes.
Cheers!
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?
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.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Decode Base64 data in java
I have a java file which will be downloaded from a location. The files are BinHex encoded.
Is there any jar file available which i can use in java code to decode the binhex file?
Please help me.
Apache commons has a class called BCodec that allows specifying custom character sequence for encoding. Maybe you can adapt it to your needs?
In any case mechanics behind Base64 and BinHex are very similar, you could take this class and update it to your needs. I think modifying char sequence may be enough.
EDIT:
Here's an implementation of BinConverter as a part of BlowfishJ library.