[Java的]进入, 在Java中做 – 输入, 在Java中输出

一个简单的入口和出口从键盘中的Java与扫描仪

import java.io.IOException;
import java.util.*; //thu vien dung lop Scanner
class java_in_out_put
{
	public static void main(String agrv[]) throws IOException
	{
		String s;
		int age;
		Double M;
		Scanner inp = new Scanner(System.in); //tao doi tuong inp thuoc lop Scanner
		System.out.print("Insert your name : "); //Lenh in ra man hinh
		s = inp.nextLine(); //nhap chuoi
		System.out.print("Insert your age: ");
		age = inp.nextInt(); //nhap so nguyen
		System.out.println("Insert your Math: ");
		M = inp.nextDouble();
		System.out.printf("My name is %s , I %d yaers old and I am %.2f math scoren", s, age, M);
		inp.close();
	}
}

接着,在输出文件. 在这个项目中,我会从文件中读取包括行INPUT.TXT, 每一行具有名称, 年龄, 工资由逗号分隔, 然后写上OUTPUT.TXT不同行的文件信息:
首席执行官:
INPUT.TXT文件内容
阮文Q,21,100000.0
阮氏乙,20,200000.0
写入到output.txt文件将被
阮文Q
21
100000.0
阮氏乙
20
200000.0

import java.io.*;
import java.util.*;

class input_file
{
	String ten[] = new String[100];
	int tuoi[] = new int[100];
	double luong[] = new double[100];
	int i=0;
	void read() throws IOException //phuong thuc doc tu file
	{
		String line[] = new String[100];
		FileInputStream f = new FileInputStream("input.txt"); //tao bien tep f
		Scanner input = new Scanner(f,"UTF-8"); //doc tu tep f su dung Scanner

		while(input.hasNextLine()) //trong khi chưa het file
		{
			line[i]= input.nextLine(); //doc 1 dong
			if(line[i].trim()!="") //neu dong khong phai rong
			{
				String item[] = line[i].split(","); //cat cac thong tin cua line bang dau phay
				ten[i] = item[0];
				tuoi[i] = Integer.parseInt(item[1]); //chuyen strin sang int
				luong[i] = Double.parseDouble(item[2]);
			}
			i++;
		}
		input.close();
	}
	void write() throws IOException //phuong thuc ghi vao file
	{
		FileOutputStream f = new FileOutputStream("output.txt");
		PrintWriter output = new PrintWriter(f);
		int j=0;
		while(j<i)
		{
			output.println(ten[j]);
			output.println(tuoi[j]);
			output.println(luong[j]);
			j++;
		}
		output.close();
	}
}
class java_in_out_file
{
	public static void main(String []agr) throws IOException
	{
		input_file file = new input_file();
		file.read();
		file.write();
	}
}