main.java
来自「java的经典例子」· Java 代码 · 共 30 行
JAVA
30 行
import java.io.*;
import java.util.zip.*;
class Main {
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: java Main <filename>");
} else {
try {
InputStream is = new FileInputStream(args[0]);
// Read the 16-bit value.
int magic = is.read() | (is.read() << 8);
if (magic == GZIPInputStream.GZIP_MAGIC) {
System.out.println("This is a GZIP file");
} else {
System.out.println("This is not a GZIP file.");
System.out.println("Its magic number is 0x" +
Integer.toHexString(magic) + " and not 0x" +
Integer.toHexString(GZIPInputStream.GZIP_MAGIC));
}
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?