一 標準設備輸入/輸出java
A 標準輸入/輸出類 System數組
B 控制檯讀寫類 Console 函數
標準輸入/輸出類 Systemspa
1 標準輸入、標準輸出、錯誤輸出流3d
// 標準輸入流 public final static InputStream in = null; //標準輸出流 public final static PrintStream out = null; //標準錯誤輸出流 public final static PrintStream err = null;
2 對外部定義屬性、環境變量的訪問code
public static java.util.Map<String,String> getenv() {
SecurityManager sm = getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getenv.*"));
}
return ProcessEnvironment.getenv();
}
public static Properties getProperties() {
SecurityManager sm = getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
return props;
}
3 快速複製數組
public static native void arraycopy(Object src, int srcPos,
Object dest, int destPos,
int length);
4 加載文件及庫blog
5 取得系統時間 get
public static native long currentTimeMillis();
6 系統退出命令it
public static void exit(int status) {
Runtime.getRuntime().exit(status);
}
PrintStream 類 // print 方法無打印 byte[] 數組重載
// 打印 boolean 值 public void print(boolean b) { write(b ? "true" : "false"); } // 打印字符 public void print(char c) { write(String.valueOf(c)); } // 打印 int 值 public void print(int i) { write(String.valueOf(i)); } // 打印 long 值 public void print(long l) { write(String.valueOf(l)); } // 打印 float 值 public void print(float f) { write(String.valueOf(f)); } // 打印 double 值 public void print(double d) { write(String.valueOf(d)); } // 打印 char[] public void print(char s[]) { write(s); } // 打印 String 值 public void print(String s) { if (s == null) { s = "null"; } write(s); } // 打印 Object 值 public void print(Object obj) { write(String.valueOf(obj)); }
另外,PrintStream 兩個重要函數io
public void write(int b) // 將指定字節寫入此流
public void write(byte buf[], int off, int len) // 將 byte[] 數組寫入此流