filedemo7.java

来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 41 行

JAVA
41
字号
/**
*Another simple file demonstration program
*Reading chracters from screen
xhcprince
*/

import java.io.*;
/*----------------------------------------------------------------------------------
	If you import java.io.*,you have to throws the IOExcception!
----------------------------------------------------------------------------------*/
public class fileDemo7
{
	public static void main(String args[]) throws IOException
	{
		int n;
		char c;

		for(int i=0; i<5; ++i)
		{
			System.out.println("Enter a chracter:");
			n = System.in.read();
			c = (char)n;
			System.in.skip(2);	//skip the enter key(the unicode is 2 bytes)

			if(Character.isLowerCase(c))
			{
				System.out.println("You've entered a lower case character " + c);
			}

			else if(Character.isUpperCase(c))
			{
				System.out.println("You've entered a upper case character " + c);
			}

			else
			{
				System.out.println("You are not entering characters!");
			}
		}
	}
}

⌨️ 快捷键说明

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