简体   繁体   中英

How to test wireless connection speed using java?

在我的编译器中,我将如何测试计算机的无线连接速度?

You can try downloading a file from the internet and simply use a start/end timer

Long start = System.nanoTime();

// download to file code goes here
URL website = new URL("http://central.maven.org/maven2/com/sun/jersey/jersey-client/1.0.2/jersey-client-1.0.2.jar");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("information.html");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

// do some validation check here that the file is successfully downloaded
Long end = System.nanoTime();
// and then measure time. you get file size (bytes) which you can use to measure speed

Also worth reading about Neflix fast.com implementation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM