Hi,
I want download a .dat file from a website in my java class.
I do it so:
FileWriter fw = null; SimpleDateFormat fmt = new SimpleDateFormat(); try { String filename_t = ("/appl/shared/file.dat"); fmt.applyPattern( " adress/file'ddMMyy'.dat' " ); Calendar cal = new GregorianCalendar(); URL url = new URL( fmt.format(cal.getTime())); Reader is = new InputStreamReader( url.openStream() ); BufferedReader in = new BufferedReader( is ); FileOutputStream file = new FileOutputStream( filename_t ); ObjectOutputStream o = new ObjectOutputStream( file ); StringWriter buffer = new StringWriter(); PrintWriter out = new PrintWriter( buffer ); for ( String s; ( s = in.readLine() ) != null; ) out.println( s ); in.close(); String result = buffer.toString(); o.writeObject( result ); o.close(); } catch ( MalformedURLException e ) { System.out.println( "MalformedURLException: " + e ); } catch ( IOException e ) { System.out.println( "IOException: " + e ); } }
Everything works, but in editor the downloaded files looks like:
nԀʹnԀʹnԀʹnԀʹnԀʹnԀʹnԀʹnԀʹ.
nԀʹnԀʹnԀʹnԀʹnԀʹ
and so on..
Any Idea what is wrong?
Regards,
Robin