on 09-28-2005 1:17 PM
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
a) Do you know what the content of the .dat file should be / look like?
b) Do you know in which ccsid (char code set id) it was written. May be you need to translate using java.nio.*
Enjoy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.