Here you can find the source of getContentEncoding(URL url)
Parameter | Description |
---|---|
url | refereneces URL |
Parameter | Description |
---|---|
IOException | when an error occurs when opening connection to URL |
public static String getContentEncoding(URL url) throws IOException
//package com.java2s; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class Main { /**// www .java2 s. co m * Returns the value of the content-encoding header field. * @param url refereneces URL * @return the content encoding of the resource that the URL references, or null if not known. * @throws IOException when an error occurs when opening connection to URL */ public static String getContentEncoding(URL url) throws IOException { String encoding = null; HttpURLConnection conn = null; try { conn = (HttpURLConnection) url.openConnection(); encoding = conn.getContentEncoding(); } finally { if (conn != null) { conn.disconnect(); } } return encoding; } }