Binhex decoding using java code [duplicate] - java

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.

Related

Java string data compression [duplicate]

This question already has answers here:
What's a good compression library for Java?
(3 answers)
Closed 9 years ago.
I have a problem. Currently I'm developing video game in java language. At this moment data files take about 100MB space even though game world is not big. I want to zip those text files ant protect them with password or some kind of encryption, but I can't find any good and free library for that.
Or maybe it's possible to pack data into some kind of archive without external libraries?
Update
I tried to download Zip4j, but it shows that I need source attachments and I can't find in library's site.
You can compress yor game data with the facilities provided by the JDK:
java.util.ZipFile and related classes to handle normal zip files
java.util.GZIPInput/OutputStream to compress data directly (no "files catalog" concept, just a blob).
java.util.DeflaterInput/OutputStream (like GZIP)
There exists a multitude of 3rd-Party compression classes. I personally like XZ for Java, because it provides excellent compression ratios and is easy to use through the standard stream interface (http://tukaani.org/xz/java.html).
For encryption, there are encrypting streams that are used just like the compression streams. Beware that anybody will be able to extract the "key" from your game files with a little knowledge and patience if they really want to.
You can use apache Compress Library for compressing file.
http://commons.apache.org/proper/commons-compress/
you can also compress using zip libraries at java.util.zip
Java provides several features that compress the data such as:
GZIPInputStream and GZIPOutputStream
you can also use zip with ZipFile (java.util.zip)
For encryption you could write your own FilterOutputStream and FilterInputStream where you use a Cipher to encrypt it.
Those features are working all without external libraries.

java best way to create and write XML [duplicate]

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.

Handmade pdf files [duplicate]

This question already has answers here:
Open source PDF library for C/C++ application? [closed]
(10 answers)
Closed 9 years ago.
It used to be, and remains, possible for one's program to output (encapsulated) postscript by simply writing some lines in a text file. To draw an 'x' one might for instance write
%!PS
%%BoundingBox: 0 0 100 100
newpath 100 0 moveto 0 100 lineto stroke
newpath 0 0 moveto 100 100 lineto stroke
showpage
Is there an equivalent method to output pdf?
Edit
Please do suggest an inelegant, regular, or luxurious way to output pdf.
An inelegant method would be one that still passes by eps. A regular one would be one that parallels the eps text file above. A luxurious method would be a comfortable API/library.
Edit2
A "regular" solution is platform neutral, but a solution in neither the first nor the third categories is. So let me clarify that I am looking for a solution using Java on android.
As discussed in the copious comments on your question, the ISO 32000-1 standard for the PDF file format can be found here. (Thanks to #mkl for the updated link).
It may not be trivial, but it would certainly be possible to create PDF files from scratch by using the most appropriate parts of this document for your application.
Well if I understood you correctly i might have done something similar in one of my Android applications.
I implemented a domain specific language for interactive questionnaires which results are extracted in pdf format. For the pdf creation I used the iText open source library. So, you can create a dsl and an api, between your dsl and a pdf creation and manipulation library, like iText. However, I don't know if you are interested in a ready solution or to develop something from scratch, so I am not sure if this helps.
You can find the code here github with some more details for the dsl(like the syntax etc.).
And here is the demo app in google play.
PDF is not a simple text format, so it is not that simple. But it should not be difficult to integrate a Java PDF library in your app, see iText, for example.

how to get the real character encoding of a file java [duplicate]

This question already has answers here:
Java : How to determine the correct charset encoding of a stream
(16 answers)
Closed 8 years ago.
Any idea about gettin the real encoding of a file like .html .txt .java and etc in java?
Since some source codes are not utf-8,I wantto change them to utf-8.
In general, it is not possible to always detect exactly what the character encoding of a text file is - there's nothing stored in a text file that tells you explicitly what the character encoding is. You can make some intelligent guesses, but don't expect that you'll always be able to find out exactly what the character encoding of a text file is.
The link that cebewee posted in the comments has more information on how to detect what the character encoding of a text file is.
You can use tools like UTFCast to batch convert file encoding. Just run them on all of your source files and you should be done. On linux, you can use 'iconv' to convert file encoding.

Parsing a csv file in Java [duplicate]

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.

Categories

Resources