-1

I have an API which will create the report and we need to pass the JRXML content(whihc is passed as string from UI) for that,Now I want to compile the JRXML content before saving it into data base,One approach I have is that I can save the JRXML content into file system and then load that file and compile it,But I don't like it because if the compilation failed I need to delete that file from file system, So wondering If I can compile the input JRXML content only before storing it into file.

I am passing the JRXML as a string to my method which should compile that JRXML string, but I don't want to store the content in file and then compile it

Alex K
  • 22,315
  • 19
  • 108
  • 236
user3817378
  • 119
  • 10
  • @PetterFriberg Please see my edit ,it is not the duplicate of the question which you refer. – user3817378 Apr 15 '16 at 04:50
  • 1
    @user3817378 `I am asking to compile the jasper string` - What do you mean? I don't know about the jasper strings and compilation of jasper string. Please explain – Alex K Apr 15 '16 at 07:52
  • A jasper string = the content in a jasper file, if so then just create a inputstream from the string [how-do-i-turn-a-string-into-a-stream-in-java](http://stackoverflow.com/questions/247161/how-do-i-turn-a-string-into-a-stream-in-java), then check the duplicate again. – Petter Friberg Apr 15 '16 at 17:47
  • @AlexK, The intention of putting the block letters was to avoid any confusion about what I was asking,I am no one to shout to anyone. – user3817378 Apr 15 '16 at 17:57
  • @AlexK It means that I want to compile the JRXML string or content of the JRXML file ,As I mention in my question ,I am passing the JRXML as a string to my method which should compile that JRXML string ,But I don't want to store the content in file and then compile. – user3817378 Apr 15 '16 at 18:01
  • @PetterFriberg That looks a solution ,I will try it. Thanks – user3817378 Apr 15 '16 at 18:01
  • 1
    If it works consider to accept the duplicate, since in the end it really is. – Petter Friberg Apr 15 '16 at 19:24

1 Answers1

1

You can also use an input stream, not necessarily a file object for the compile() method like mentioned in the jasper docs.

hering
  • 1,956
  • 4
  • 28
  • 43