RE: [Httpunit-develop] getText
Brought to you by:
russgold
From: Stephan L. <ste...@vi...> - 2002-02-27 21:21:43
|
try PrintWriter pw =3D new PrintWriter ( new FileWriter ( fileName, = /*append*/ false ), /*autoFlush*/ true ); pw.println ( pageSource ); using an ObjectOutputStream, you will be serializing a given object, = which is not the same as writing a String instance to file. : ) Stephan -----Original Message----- From: TAFFL [mailto:co...@th...] Sent: Wednesday, February 27, 2002 2:52 PM To: htt...@li... Subject: [Httpunit-develop] getText I am attempting to write out the HTML code from my current form to disk = to allow me to come back later and compare a newer page to check for = discrepancies.=20 I am using the following code: public void writeOutHtmlPage(WebResponse wr, String fileName) throws Exception { String pageSource =3D wr.getText(); try { //now prepare the file for output FileOutputStream out =3D new FileOutputStream(fileName); ObjectOutputStream oos =3D new ObjectOutputStream(out); oos.writeObject(pageSource); oos.flush(); } catch (Exception e) { System.out.println("Problem serializing: "+ e); } } However, in the TXT file that I receive as output form this, I am = getting some bogus characters in the front (what appears to be 7 ASCII = characters at the very beginning of the file). Is this something from = the getText method or did I make a Java error? __________________________________________________ D O T E A S Y - "Join the web hosting revolution!" http://www.doteasy.com _______________________________________________ Httpunit-develop mailing list Htt...@li... https://lists.sourceforge.net/lists/listinfo/httpunit-develop |