KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Below is my code: private HttpURLConnection connection; private InputStream is; public void upload() { try { URL url = new URL(URLPath); connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(30000); connection.setReadTimeout(30000); connection.setDoInput(true); connection.setUseCaches(false); connection.connect(); is = connection.getInputStream(); } catch (Exception e) { e.printStackTrace(); } } public void stopupload() { connection = null; is = null; } When I upload file, the line is = connection.getInputStream(); will spend a lot of time to get reply. So I want to implement a stop function as stopupload() . But if I call stopupload() while the code is handling at line is = connection.getInputStream(); , it still needs to wait for its reply. I want to stop waiting at once while implement stopupload() . How can I do it?
Tags (comma-separated)
Save Edits
Cancel