• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing to a temporary file in Memory

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

Greetings!

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!

Thanks
Sumon
 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic