About improving the word throttling problem and the fourth time Java job

Source: Internet
Author: User

Import Java.io.FileInputStream;
Import Java.io.FileOutputStream;
Import java.io.IOException;

public class CopyFile {
/**
* @param args
*/
public static void Main (string[] args) {
try {
FileInputStream fis = new FileInputStream ("A.mp3");
FileOutputStream fos = new FileOutputStream ("Temp.mp3");
int read = Fis.read ();
byte[] buf = new byte[1024];
int len = 0;
while ((Len=fis.read (BUF))! =-1) {
Fos.write (Buf,0,len);
Read = Fis.read ();

}

Fis.close ();
Fos.close ();
} catch (IOException e) {
E.printstacktrace ();
}
}
}

Through this work, mainly to the code to add

byte[] buf = new byte[1024];
int len = 0; This code can increase the read byte speed

It then modifies the contents of the following loop:

while ((Len=fis.read (BUF))! =-1) {
Fos.write (Buf,0,len);

After the modification is finished, the speed of reading the song becomes less than 2 seconds in the original half, and the test is successful.

About improving the word throttling problem and the fourth time Java job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.