欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

java第十章总结

发布时间:2023/12/18 编程问答 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 java第十章总结 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

文件执行

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类型的异常。

总结

以上是生活随笔为你收集整理的java第十章总结的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。