📄 getcontenttype.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -