• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Basic I/O: PrintWriter

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a very basic I/O question concerning PrintWriter. I am basically new to JAVA, so any help would be appreciated.
I have a method:
public void onResponseSent(PrintWriter writer){
}
How can I call this method?. My main aim is to transfer the contents of an XML file from one class to this class using the above method. In this method then I want to manipluate the contents of the XML document. How can I achieve this?
I can only use the above method, so any helpful code would be appreciated.
As you can see, its a stupid q, but hopefully somebody can help me out. Thanks!
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The newxml file is either a local file or a URL:
BufferedReader in = new BufferedReader(new InputStreamReader(newxml));
PrintWriter xmlout = new PrintWriter(new FileOutputStream(xmlfile));
String l;
for( l = null; (l = in.readLine()) != null; ) {
xmlout.println(l);
}
xmlout.close();
I hope this helps!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic