Đang chuẩn bị liên kết để tải về tài liệu:
Java 6 Platform Revealed phần 4

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Tham khảo tài liệu 'java 6 platform revealed phần 4', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 48 CHAPTER 3 I O NETWORKING AND SECURITY UPDATES cookies.append cookie.toString Map to return Map String List String cookieMap new HashMap String List String requestHeaders Convert StringBuilder to List store in map if cookies.length 0 List String list Collections.singletonList cookies.toString cookieMap.put Cookie list System.out.println CookieMap cookieMap Make read-only return Collections.unmodifiableMap cookieMap In Java 6 the ListCookieHandler turns into the CookieManager class. The cookieJar that is used as the cache becomes the CookieStore. One thing not in this implementation of CookieHandler is a policy for storing cookies. Do you want to accept no cookies all cookies or only cookies from the original server That s where the CookiePolicy class comes into play. You will explore CookiePolicy more later. The last part of the Java 5 situation is the Cookie class itself. The constructor parses out the fields from the header line. Listing 3-5 shows an implementation that will be replaced in Java 6 by HttpCookie. The Java 6 version will also be more complete. Listing 3-5. Implementing a Cookie Class to Save for Java 5 import java.net. import java.text. import java.util. public class Cookie String name String value URI uri CHAPTER 3 I O NETWORKING AND SECURITY UPDATES 49 String domain Date expires String path private static DateFormat expiresFormatl new SimpleDateFormat E dd MMM yyyy k m s GMT Locale.US private static DateFormat expiresFormat2 new SimpleDateFormat E dd-MMM-yyyy k m s GMT Locale.US public Cookie URI uri String header String attributes header.split String nameValue attributes 0 .trim this.uri uri this.name nameValue.substring 0 nameValue.indexOf this.value nameValue.substring nameValue.indexOf 1 this.path this.domain uri.getHost for int i 1 i attributes.length i nameValue attributes i .trim int equals nameValue.indexOf if equals -1 continue String name nameValue.substring 0 equals String value nameValue.substring equals 1 if name.equalsIgnoreCase .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.