have src file in attachment.
description: creating buffer with 20 MB size. reading and appending readed size
into StringBuilder. after reading - show StringBuilder contents. on my machine
with Mustang b101 we read about 1440
bytes every time, instead of read 20 MB. have great perfomance problem and need
REAL buffer, but dont know what to do...
package httpclient;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
public class HttpClientTest {
int size = 1024*1024*20;
private String newline = "\n";
public HttpClientTest() {
try {
HttpClient client = new HttpClient();
GetMethod get = new GetMethod("http://idds-suse/ISO/solaris/sol-10-u2-ga-x86-dvd-iso-a.zip");
client.executeMethod(get);
InputStream in = get.getResponseBodyAsStream();
File f = new File("/home/ss/temp/httpclientout.iso");
f.createNewFile();
OutputStream out = new BufferedOutputStream(new FileOutputStream(f), size);
int read = 0;
int completed = 0;
byte[] buffer = new byte[size];
StringBuilder sb = new StringBuilder();
long start = System.currentTimeMillis();
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
completed = completed + read;
sb.append(read);
sb.append(newline);
}
long end = System.currentTimeMillis();
double done = completed/1024/1024;
System.out.println(done + " MB in " + (end - start) + " millis");
out.flush();
out.close();
get.releaseConnection();
System.out.println(sb.toString());
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new HttpClientTest();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]