输出输入

    public class Input {

        public static void main (String[] args){

            try {
                /**
                 * 打开文件流进行读取
                 */
                Scanner scf  = new Scanner(Paths.get("/project/java/JavaStudy/src/knowledge/base/input.txt"));
                System.out.println(scf.nextLine());
                System.out.println(scf.next());
                System.out.println(scf.nextInt());
                scf.close();

                /**
                 * 写文件
                 */
                PrintWriter pw = new PrintWriter(new File("/project/java/JavaStudy/src/knowledge/base/input.txt"));
                //会覆盖原来的内容
                pw.println("write something");
                pw.append("hello");
                pw.close();

                /**
                 * 读取控制台流
                 */
                Scanner sc  = new Scanner(System.in);
                System.out.println(sc.nextLine());
                System.out.println(sc.next());
                System.out.println(sc.nextInt());
                sc.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
05-11 11:35