• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Writing to a temporary file in Memory

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!

Posts: 24594
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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!