iomethods.java

来自「数据结构与算法Java语言版(美)Adam Drozdek著」· Java 代码 · 共 27 行

JAVA
27
字号
import java.io.*;public class IOmethods {    public void writeString(String s, RandomAccessFile out) throws IOException {        for (int i = 0; i < s.length(); i++)            out.writeChar(s.charAt(i));    }    public String readString(int len, RandomAccessFile in) throws IOException {        String s = "";        for (int i = 0; i < len; i++)            s += in.readChar();        return s;    }    public String readLine() throws IOException {        int ch;        String s = "";        while (true) {            ch = System.in.read();            if (ch == -1 || (char)ch == '\n') // end of file or end of line;                 break;            else if ((char)ch != '\r')        // ignore carriage return;                 s = s + (char)ch;        }        return s;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?