Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Castor trouble  RSS feed

 
Matthew Richen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I want to use Castor to take POJOs and marshal them into xml elements, which will then be written to strings. The objects themselves are pretty simple but there will be lots of them. In any case, I got a rough version of the program written, but I couldn't find any way to clear the contents of the StringWriter that I used to create the Marshaller. I ended up instantiating a new StringWriter and Marshaller and calling setMapping() each time through the loop. Is there a less expensive way to do this? Should I even worry about it?

thanks.
 
Paul Clapham
Sheriff
Posts: 22480
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's expensive about that? You think that clearing a StringWriter would be in some way less "expensive" than just creating a new one and letting the old one be garbage collected? It ain't necessarily so. But in this case you only have the one option ("clear" isn't a natural operation on a Writer) so don't worry about it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!