1

Is there any java program is available to arrange java program according to perfect indentation,syntax...? To make clear on my question (i.e) if a code snippet is like this...

Actual Code

if(true) { a=1; b=1; c=1; }

Expected result

if(true) {

   a=1;

   b=1:

   c=1;

}

Expected result can be achieved using eclipse IDE. But i want to do that using java program since am having several programs like this....

gnubala
  • 103
  • 2
  • 3
  • 7
  • 1
    Have a look here: http://stackoverflow.com/questions/996646/stand-alone-java-code-formatter-beautifier-pretty-printer – MrSmith42 Jan 16 '13 at 13:10
  • Is there any way to use Eclipse sources to achieve the output? The way they given on the above link is not clear & clarity to me. I need more clarity/usage of that tool in command line for understandings... – gnubala Jan 16 '13 at 13:32
  • I doubt the you will find **simple** code to do this. Such code will need to understand Java syntax and keep some sort of AST. If you feel that the eclipse GUI doesn't provide enough functionality, you can peek at the eclipse sources. – David Soroko Jan 16 '13 at 13:16
  • It's not an issue of Eclipse's *functionality*, it's an issue of the OP not wanting to load up every project/file into Eclipse and run formatting. – Dave Newton Jan 16 '13 at 13:31
  • Could you pls help me on this by providing such a link to use eclipse sources... like eclipse code formaters? – gnubala Jan 16 '13 at 13:34
  • @Dave Newton I thought this is about lack of functionality such as scripting. The OP didn't mention multiple projects at all. – David Soroko Jan 16 '13 at 15:25
  • @DavidSoroko "i want to do that using java program since am having several programs like this...." – Dave Newton Jan 16 '13 at 15:28
  • @gnubala can't help you there, you will need to google. That code will be using the Eclipse API no doubt - so you will not get a standalone code. – David Soroko Jan 16 '13 at 15:28

0 Answers0