I have this code that loads a webpage:
HttpURLConnection connection;
private String downloadContent() {
InputStream content;
Source parser;
try {
content = connection.getInputStream();
parser = new Source(content);
content.close();
return parser.toString();
} catch (Exception e) {
return null;
}
}
While downloading, I tried to get the amount of downloaded data, and if it reaches the limit, I stopped loading, but I did not find a way to do this. If anyone knows how to do this, please tell me.
Now I want to limit the download time. Example: if the download passes after 20 seconds, I stop it. I want to do this because my program is a web browser, and if by mistake it starts downloading a large file, it will get stuck in the download, and I donβt want to do this, so the filter is loaded by size, but as I donβt know, filtering time will prevent this problem.