Java alternative to PHP Tokenizer - java

Is there any Java alternative to PHP Tokenizer?
http://php.net/manual/en/book.tokenizer.php
Edit: I mean Java class that parses Java like PHP Tokenizer parses PHP.

I quickly scanned the documentation you linked to. It looks like functionality for parsing PHP code.
If that is indeed what you are looking for, you might find the JavaParser project useful. It contains functionality for parsing Java source code.
This page contains some usage examples.

Related

Getting php file attributes through java code

I have a php code file and i have to get all the attributes defined in that class using java code. Is there a way of doing so other than travesing through the file.
Look for a parser generator. My personal favorite is antlr.

How do I display specific lines of text from a website in Java?

I am trying to recreate a C# program I made in Java. I used the the htmlagilitypack and XPaths to display text from a website in the C# program. Is there a library for Java in which I can use XPaths or is there a better way to do this? Thanks!
Check out jsoup -- a fairly-recent and decent-looking Java HTML parsing library, which seems quite powerful and easy to use, with nice CSS-like selector syntax for accessing content.

NSCoding to java

Hee,
I currently am using NSCoding to write my objects to data and save them to an file in objective-c.
Does anybody know if there is a way to use the same coding to decode the object structure in an Java application?
Thanks
Quite probably the easiest way is to use the third-party plist Java library.
Otherwise, you've got the problem that OS X supports two different types of property list — XML and binary. XML's easy enough and the relevant wikipedia page even includes a quick summary of the tags. You can use the command line tool plutil to convert any property list to XML format but the default is binary so that's not much help if you need there to be no manual step in between.
Apple don't seem to have a formal documentation of the binary format, but their code is open source so you can reverse engineer it from here.

Importing .eps file into Java program

I need to parse an Encapsulated Post Script file into Java program. More specifically, I need to be able to extract simple vectors and curve elements from it, and manipulate them after this. Is there a Java library which can do this?
ToastScript looks like it may be what you are looking for.

Can Java POI write image to word document?

Anyone know if it is possible?
And got any sample code for this?
Or any other java API that can do this?
The Office 2007 format is based on XML and so can probably be written to using XML tools. However there is this library which claims to be able to write DocX format word documents.
The only other alternative is to use a Java-COM Bridge and use COM to manipulate word. This is probably not a good idea though - I would suggest finding a simpler way.
For example, Word can easily read RTF documents and you can generate .rtf documents from within Java. You don't have to use the Microsoft Word format!
As others have said POI isn't going to allow you to do anything really fancy - plus it doesn't support Office 2007+ formats. Treating MS Word as a component that provides this type of functionality via COM is most likely the best approach here (unless you are running on a non-Windows OS or just can't guarantee that Word will be installed on the machine).
If you do go the COM route, I recommend that you look into the JACOB project. You do need to be somewhat familiar with COM (which has a very steep learning curve), but the library works quite well and is easier than trying to do it in native code with a JNI wrapper.
If you are using docx, you could try docx4j.
See the AddImage sample
Surely:
Take a look at this: http://code.google.com/p/java2word
Word 2004+ is XML based. The above framework gets the image, convert to Base64 representation and adds it to the XML.
When you open your Word Document, there will be your image.
Simple like this:
IDocument myDoc = new Document2004();
myDoc.getBody().addEle("path/myImage.png"));
Java2Word is one API to generate Word Docs using obviously Java code. J2W takes care of all implementation and XML generation behind the scenes.
As far as can be gathered from the project website: no.
POI's HWPF can extract an MS Word document's text and perform simple modifications (basically deleting and inserting text).
AFAIK it can't do much more than that.
Also keep in mind that HWPF works only with the older MS Word (97) format, not the latest ones.
Not sure if Java out of the box can do it directly. But i've read about a component that can pretty much do anything in terms of automating word document generation without having Word. Aspose Words
JasperReports uses this API alternatively to POI, because it supports images:
JExcelAPI
I didn't try it yet and don't know how good/bad it is.

Categories

Resources