Okhttp check file size without dowloading the file
问题 The common examples for okhttp cover the scenarios of get and post. But I need to get the file size of a file with a url. Since I need to inform the the user, and only after getting their approval to download the file. Currently I am using this code URL url = new URL("http://server.com/file.mp3"); URLConnection urlConnection = url.openConnection(); urlConnection.connect(); int file_size = urlConnection.getContentLength(); mentioned in this stackoverflow question How to know the size of a file