有没有办法为输入流设置超时?
我当前的代码如下所示:
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");
最佳答案
我认为根据您的要求,您可以使用
HttpURLConnection.setReadTimeout()
也许这些链接会对您有所帮助。
关于java - 输入流超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12914484/