This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing to a temporary file in Memory  RSS feed

Sumon Mukherjee
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have this method that accepts an empty Jdom document as an input argument. There is also a String variable which contains the XML stuff which I need to add to the Jdom document. For eg:
public static Document loadXML(Document jDoc, String strTags)
String will contain-
strTags = "<RequestBody><first>Sumon</first><last>M</last></RequestBody>";
I add this string to my Jdom document and my method returns the modified jdom document which can later be used for other functions.

The problem is i already have the content in my string variable and dont want to create a file in the phsical memory.

One way i can think of is to create a temporary file to wrap this string and delete it on exiting. But this approach has it own problems, say if there are 100's of users logged in and my temporary file has exclusive lock on it.....the waiting time will be too much n my users will prefer not to use my site!

Is there any other way i can wrap this string/convert to File object so that i can ue the temporary Jdom document from the memory.

Any help in this regard will be highly appreciated!

Paul Clapham
Posts: 22271
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why you need to create a File. I couldn't quite understand what you were trying to pass that String into, but if you want JDOM to parse the XML it contains, surely JDOM can parse from sources other than Files? (I don't have its API documentation on hand but I'm expecting you do.) For example can it parse from a Reader? Like a StringReader?
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!