public void addFile(String name, String file) throws IOException { if (boundary == null) { boundary = Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value. } files.put(name, file); }
Response doSend() throws IOException { connection.setRequestMethod(this.verb.name()); if (connectTimeout != null) { connection.setConnectTimeout(connectTimeout.intValue()); } if (readTimeout != null) { connection.setReadTimeout(readTimeout.intValue()); } if (boundary != null) { connection.setRequestProperty(CONTENT_TYPE, "multipart/form-data; boundary=" + boundary); } addHeaders(connection); if (verb.equals(Verb.PUT) || verb.equals(Verb.POST)) { addBody(connection, getByteBodyContents()); } return new Response(connection); }
void show() { // 打印任务执行的结果 String result; if (connectFinish != 0) result = Long.toString(connectFinish - connectStart) + "ms"; else if (failure != null) result = failure.toString(); else result = "Timed out"; System.out.println(address + " : " + result); shown = true; }
Response doSend(RequestTuner tuner) throws IOException { connection.setRequestMethod(this.verb.name()); if (connectTimeout != null) { connection.setConnectTimeout(connectTimeout.intValue()); } if (readTimeout != null) { connection.setReadTimeout(readTimeout.intValue()); } tuner.tune(this); addHeaders(connection); if (verb.equals(Verb.PUT) || verb.equals(Verb.POST)) { addBody(connection, getByteBodyContents()); } return new Response(connection); }
/** * Creates a byte array representation from the specified long value, using Java's standard * method. * * @param integer value to be converted * @return byte array */ public static byte[] token(final long integer) { return integer >= Integer.MIN_VALUE && integer <= Integer.MAX_VALUE ? token((int) integer) : token(Long.toString(integer)); }
@Override public int compare(VisorLogFile f1, VisorLogFile f2) { return Long.compare(f2.lastModified(), f1.lastModified()); }
@Override public int compare(Event o1, Event o2) { return Long.compare(o1.localOrder(), o2.localOrder()); }