කරන හැටි දාන්න බැරිද?
ඕක buffer එකේ අවුලක් නෙවෙයි. උබ stream එක රීඩ් කරන්නෙ බයිට් එකෙන් බයිට් එක නැතුව බ්ලොක් ලෙවල් එකෙන් නෙවෙයි. එක්කො inputstream එක BufferedInputStream එකක wrap කරල රීඩ් කර ගනින් නැත්තම් read(byte[], int, int) එක යූස් කරපං

කරන හැටි දාන්න බැරිද?
ඕක buffer එකේ අවුලක් නෙවෙයි. උබ stream එක රීඩ් කරන්නෙ බයිට් එකෙන් බයිට් එක නැතුව බ්ලොක් ලෙවල් එකෙන් නෙවෙයි. එක්කො inputstream එක BufferedInputStream එකක wrap කරල රීඩ් කර ගනින් නැත්තම් read(byte[], int, int) එක යූස් කරපං

mehemada ban?Try above solution![]()

OutputStream out = new BufferedOutputStream(new FileOutputStream(localFileName));
කරන හැටි දාන්න බැරිද?![]()
try (FileOutputStream fos = new FileOutputStream(file)) {
byte[] buf = new byte[1024*4096];
int bytesRead;
while ((bytesRead = is.read(buf, 0, buf.length)) != -1) {
fos.write(buf, 0, bytesRead);
}
}
පට්ට මේක තමා මට ඕන උන උත්තරෙ. 10+නියෙමෙට තියෙනව.. හැබැයි වැඩේ තියෙන්නෙ මගේ 8mbps එකෙන් 3mb file එකක් dowload වෙන්න මේ ක්රමෙන් 2min කටත් වඩා යනවනෙ..
BUILD SUCCESSFUL (total time: 1 minute 52 seconds)
නිකන් browser එකෙන් මේක download කලොත් තත් 10ක් වත් යන්නෙ නෑ. කොහොමද ඒක හදා ගන්නෙ.
1. is.read(byte[],int,int) 1024*4096or wrap it like this:PHP:try (FileOutputStream fos = new FileOutputStream(file)) { byte[] buf = new byte[1024*4096]; int bytesRead; while ((bytesRead = is.read(buf, 0, buf.length)) != -1) { fos.write(buf, 0, bytesRead); } }
bis = new BufferedInputStream(is);
and then:
bis.read();
1. is.read(byte[],int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 40 seconds)
2.wrap bis.read() 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 54 seconds)
3.wrap bis.read(byte,int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 29 seconds)
still no luck.. මම මේක email attachment එකකින් ගන්නෙ. මුල් ටිකට තත් 3ක් වගේ යන්නෙ. download වෙන ටිකට තමා ඉතුරු ඔක්කොම ටික යන්නෙ..
1. is.read(byte[],int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 40 seconds)
2.wrap bis.read() 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 54 seconds)
3.wrap bis.read(byte,int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 29 seconds)
still no luck.. මම මේක email attachment එකකින් ගන්නෙ. මුල් ටිකට තත් 3ක් වගේ යන්නෙ. download වෙන ටිකට තමා ඉතුරු ඔක්කොම ටික යන්නෙ..
මම නම් දන්න විදියට ඕක ඔහොම කරන්න බෑ. ඕකට threading දාන්න ඕනේ, file එක split වෙන්න download වෙන්න ඕනේ එතකොට speed වෙන්නේ.

vena link ekak try karala baluwada...1. is.read(byte[],int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 40 seconds)
2.wrap bis.read() 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 54 seconds)
3.wrap bis.read(byte,int,int) 1024*4096
BUILD SUCCESSFUL (total time: 1 minute 29 seconds)
still no luck.. මම මේක email attachment එකකින් ගන්නෙ. මුල් ටිකට තත් 3ක් වගේ යන්නෙ. download වෙන ටිකට තමා ඉතුරු ඔක්කොම ටික යන්නෙ..
url එකක් නෑනෙ...apache commons io lib එක use කරල බලන්න. ඒකත් slow නම් වෙන අවුලක්
org.apache.commons.io.FileUtils.copyURLToFile(URL, File)
Multipart multipart = (Multipart) message.getContent();
BodyPart bodyPart = multipart.getBodyPart(0);
InputStream is = bodyPart.getInputStream();
File file = new File(bodyPart.getFileName());
try (FileOutputStream fos = new FileOutputStream(file)) {
byte[] buf = new byte[4096];
int bytesRead;
while ((bytesRead = is.read(buf, 0, buf.length)) != -1) {
fos.write(buf, 0, bytesRead);
}
}
url එකක් නෑනෙ...
PHP:Multipart multipart = (Multipart) message.getContent(); BodyPart bodyPart = multipart.getBodyPart(0); InputStream is = bodyPart.getInputStream(); File file = new File(bodyPart.getFileName()); try (FileOutputStream fos = new FileOutputStream(file)) { byte[] buf = new byte[4096]; int bytesRead; while ((bytesRead = is.read(buf, 0, buf.length)) != -1) { fos.write(buf, 0, bytesRead); } }