java - decompile a .class file programmatically -


I am currently working on a project that lets me java file one. To wit. I have a program that should read the class file and decompile it and the resulting Java source code is written in a file. Please help me to do this. EDIT: I'm completely new to the world of decompilers. I have gone through some APIs, but I do not know what kind of use and what to use. Any kind of help would really be appreciated - edit:
I tried to use it:

  import com.strobel.decompiler *; Import java.io * *; Public class java code {public static zero main (string [] args throws exceptions {decompileee (); } Private static vide decompily () throws exceptions {Final DecompilerSettings Settings = DecompilerSettings.java Default (); Last file output stream stream = new file output stream ("C: /jp/decompiled.java"); Final OutputStream Vibrator Writer = New OutputStream Water (Stream); Decompiler.decompile ("C: /jp/X.class", new plaintext output (author), settings); Println ("success"); }}   

But the above code has created a file called "Decompiled. Java", which is in a scpecified directory. But the file is an empty file.

includes a Java Decompiler Framework, it is written in Java, and it should be called as a library There may not be too many documents yet, but I'm an author, and if you are in trouble, then I can help you - just contact me on a bitbuck.

A simple example of how to decode java.lang. :

  final DecompilerSettings settings = DecompilerSettings.javaDefaults (); Try (Final FileOutputStream Stream = New FileOutputStream ("path / to / file"); Final OutputStream Vector Author = New OutputStream Water (Stream)) {Decompiler.decompile ("java.lang.String", new plaintext output (author), Settings); } Hold (last IOException e) {// handle error}   

you .class file path to decompile () method class name Instead.

If you are not using Java 7, manually flush / close your I / O resources, such as:

  {Final FileOutputStream Stream = Try the new FileOutputStream ("path / to / file"); {Try Outputstream Whiter Writer = New OutputStream Water (Stream); Try {Decompiler.decompile ("java.lang.String", new plaintext output (author), DecompilerSettings.java defaults ()); } Finally {writer.close (); }} Finally {stream.close (); }} Hold (last IOException e) {// handle error}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -