有没有办法为 InputStream 设置超时?
我当前的代码如下所示:
public class DownloadFile implements Runnable {
private EventHandler eh;
private String source;
private String destination;
public void run(){
try {
Log.d("Download", "Download... " + source);
URL url = new URL(source);
URLConnection connection = url.openConnection();
connection.connect();
int fileLength = connection.getContentLength();
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(destination + "t");