Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Basic I/O: PrintWriter

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; ) {
I hope this helps!
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic