⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 charsdemo.java

📁 nanjing university cs 的java课件。 对新手很有用。付课件中源码。
💻 JAVA
字号:
import java.io.*;

public class CharsDemo {
	public static void main(String[] args) throws IOException {
		String tmp = "abcdefghijklmnopqrstuvwxyz";
		byte b[] = new byte[tmp.length()];
		tmp.getBytes(0, tmp.length(), b, 0);
		ByteArrayInputStream n1 = new ByteArrayInputStream(b);
		ByteArrayInputStream n2 = new ByteArrayInputStream(b, 0, 3); // abc
		int c;
		for(int i = 0; i < 2; i++) { // 打印大小写字母表
			while( (c = n1.read() ) != -1) {
				if (i == 0) {
					System.out.print( (char) c);
				}
				else {
					System.out.print(Character.toUpperCase((char)c));
				}
			}
			System.out.println();
			n1.reset();
		} //将读指针移到字节数组的开始
	}
}

⌨️ 快捷键说明

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