aspose file tools*
The moose likes Java in General and the fly likes java code on as a output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java code on as a output" Watch "java code on as a output" New topic
Author

java code on as a output

naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi ranchers,


Is that possible to write a java source program that print itself as output ??
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

yes


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Keith Rainey
Ranch Hand

Joined: Jan 19, 2011
Posts: 66

Read this thread: here


Keith Rainey
OCPJP6
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi fred rosenberger ,

i follow your link but the following store itself in string array and then print itself through in loop.this i was looking for some robust method.



by the way thanks .
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

it doesn't quite store itself, as that would be infinitely recursive - it stores a sub-set of itself.

What do you mean by a 'robust method'? What are you actually trying do do? It would be much easier if you told us what you really want, rather than ask a vague question and then tell me my answer isn't what you were looking for.
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

what i want is write a simple java program and using Java API or some other way (Robust way) to print the program code itself.
note that in the program should print itself i without any duplication code. as it was in above example.

Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Have a look at the link Keith Rainey has posted - it gives you hints how to do that!


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

and here a link which writes Quine in all possible languages,

http://www.nyx.net/~gthompso/quine.htm

There are about 4 or 5 real java solutions too!
naveen yadav
Ranch Hand

Joined: Oct 23, 2011
Posts: 384

hi Sam Mercs,

i follow your link nothing new was there were same examples which uses string array and duplicate the source code

Although the link provided by Keith Rainey is good in-comparison
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java code on as a output