static public void copyFile2null(String filenameIn, int buffer) throws IOException { long lenIn = new File(filenameIn).length(); if (debug) System.out.println("read " + filenameIn + " len = " + lenIn); InputStream in = new FileInputStream(filenameIn); long start = System.currentTimeMillis(); IO.copy2null(in, buffer); double took = .001 * (System.currentTimeMillis() - start); in.close(); double rate = lenIn / took / (1000 * 1000); System.out.println(" copy (" + filenameIn + ") took = " + took + " sec; rate = " + rate + "Mb/sec"); }
count = IO.copy2null(bis, bufferSize); else count = IO.copyB(bis, out, bufferSize);
count = IO.copy2null(bis, bufferSize); else count = IO.copyB(bis, out, bufferSize);
count = IO.copy2null(is, bufferSize); else count = IO.copyB(is, out, bufferSize);
public void run() { try { for (int i = 0; i < numReads; i++) { String urls = nextUrl(); URL url = new URL(urls); if (show) System.out.printf("%d %d Send %s%n", who, i, urls); InputStream inputStream = url.openConnection().getInputStream(); long size = IO.copy2null(inputStream, 10 * 1000); if (show) System.out.printf(" data size= %d%n",size); //System.out.printf(who + "end= %d%n", System.currentTimeMillis()); } //System.err.println(" thread #" + threadId + " done"); } catch (Exception exc) { exc.printStackTrace(); } finally { synchronized (threadsRunning) { threadsRunning[0]--; } } } }));
public void run() { try { for (int i = 0; i < numReads; i++) { String urls = nextUrl(); URL url = new URL(urls); if (show) System.out.printf("%d %d Send %s%n", who, i, urls); InputStream inputStream = url.openConnection().getInputStream(); long size = IO.copy2null(inputStream, 10 * 1000); if (show) System.out.printf(" data size= %d%n",size); //System.out.printf(who + "end= %d%n", System.currentTimeMillis()); } //System.err.println(" thread #" + threadId + " done"); } catch (Exception exc) { exc.printStackTrace(); } finally { synchronized (threadsRunning) { threadsRunning[0]--; } } } }));
void send() throws IOException { HttpGet method = null; try { method = new HttpGet( reqUrl ); method.getParams().setParameter(AllClientPNames.HANDLE_REDIRECTS,true); HttpResponse response = httpClient.execute(method); result.setStatusCode(response.getStatusLine().getStatusCode()); InputStream is = response.getEntity().getContent(); //versus InputStream is = method.getResponseBodyAsStream(); if ( is != null ) result.setBytesRead( IO.copy2null(is, 10 * 1000 )); // read data and throw away //versus result.setBytesRead( IO.copy2null( method.getResponseBodyAsStream(), 10 * 1000 )); // read data and throw away } finally { if ( method != null ) method.releaseConnection(); } } }