文件执行
Runtime ec = Runtime.getRuntime();
ec.exec(String command);
文件字节输入流
try{
FileInputStream in = new FileInputStream("hello.txt");}
catch(IOException e){}
int read();int read(byte b[]);int read(byte b[],int off,int len);
输出
File f=new File("abc.txt");
FileOutputStream out=new FileOutputStream (f);
void write(int b);void write(byte[] array);void write(byte[] array, int offset, int length); void close();
文件字符输入输出流
FileReader FileWriter
缓冲流
BufferedReader 读取一行 readLine();
数据流
DataInputStream
public String readUTF(); 读入一个已使用UTF-8修改版格式编码的字符串
public String readLine();
public boolean readBoolean;
public int readInt();
public byte readByte();
public char readChar(); 等等一系列读取基本数据类型的方法
如果发生I/O类型错误,会抛出IOException类型的异常。
DataOutputStream
public void writeBoolean(boolean b); 将一个boolean值以1-byte形式写入基本输出流。
public void writeByte(int v); 将一个byte值以1-byte值形式写入到基本输出流中。
public void writeBytes(String s); 将字符串按字节顺序写入到基本输出流中。
public void writeChar(int v); 将一个char值以2-byte形式写入到基本输出流中。先写入高字节。
public void writeInt(int v); 将一个int值以4-byte值形式写入到输出流中先写高字节。
public void writeUTF(String str);
public int size(); 返回written的当前值。
如果发生I/O类型错误,会抛出IOException类型的异常。