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

📄 字节数组输入流中所读取的英文字母变成大写字母.txt

📁 因此本系统的目标就是让顾客方便快捷和满意的购物。为了达到这一目标
💻 TXT
字号:
import java.io.*;
public class ByteArrayStreamDemo{
  public static void main(String args[]) throws Exception
   {     
	  String s = "hello world";
      byte [] b = s.getBytes();   
 	  ByteArrayInputStream bis = new ByteArrayInputStream(b); 
	  ByteArrayOutputStream bos = new ByteArrayOutputStream();
	  transform(bis,bos); 
//返回一个字节数组,并把字节数组中的所有数据转换成字符串输出
      System.out.println(bos.toString());  
      bis.close();
bos.close();
   }
   public static void transform(InputStream is, OutputStream os) throws Exception{
	   int ch;
	   while( ( ch =is.read() ) != -1 ){ //判断是否结束
int upperCh = (Character.toUpperCase((char)ch));  //字符包装类Character有一//个方法toUpperCase可以将字符变为大写,然后再用
//到强制类型转换
		   os.write(upperCh);
	   }
   }
}

⌨️ 快捷键说明

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