java.lang.NegativeArraySizeException: -1 downloading file on Android with URLConnection
问题 so I've tried to implement https://stackoverflow.com/a/1718140/13592426 this function for downloading file in my app, but I didn't succeed, and want to find out why. Here's the code: public class Receiver extends BroadcastReceiver { public static void downloadFile(String url, File outputFile) { try { URL u = new URL(url); URLConnection conn = u.openConnection(); int contentLength = conn.getContentLength(); DataInputStream stream = new DataInputStream(u.openStream()); byte[] buffer = new byte