getcontenttype.java

来自「Developing Games in Java 源代码」· Java 代码 · 共 22 行

JAVA
22
字号
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;

public class GetContentType {

    public static void main(String[] args) throws IOException {
        if (args.length != 1) {
            System.out.println("Shows the value of the " +
                "\"content-type\" header field of a remote file.");
            System.out.println("Usage: GetContentType (url)");
            System.out.println(
                "Example: GetContentType http://www.yahoo.com");
        }
        else {
            URL url = new URL(args[0]);
            URLConnection connection = url.openConnection();
            System.out.println(connection.getContentType());
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?