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

📄 bytereadtest.java

📁 本java源程序包括了大量的学习程序(共27章)方便大家学习
💻 JAVA
字号:
import java.io.*;
class ByteReadTest
{
  public static void main(String argv[])
  {
    int b;
    byte buff[] = new byte[2500];
    try
    {
      FileInputStream readfile = new FileInputStream("aaa.txt");
      b = readfile.read(buff,0,2500);
      try
      {
        String str = new String(buff,0,b,"Default");
        System.out.println("读取内容为:"+str);
        System.out.println("字符串长度为:"+b+".");
        System.out.println("数组中位置为:"+0+"; ASCII码为:"+buff[0]+"; 对应字符为:"+"\""+(char)buff[0]+"\".");
        System.out.println("数组中位置为:"+(b-1)+"; ASCII码为:"+buff[b-1]+"; 对应字符为:"+"\""+(char)buff[b-1]+"\".");
        if(b%2==0) System.out.println("数组中位置为:"+(b/2)+"; ASCII码为:"+buff[b/2]+"; 对应字符为:"+"\""+(char)buff[b/2]+"\".");
        System.out.println("数组中位置为:"+b+"; ASCII码为:"+buff[b]+"; 对应字符为:"+"\""+(char)buff[b]+"\" .");
        System.out.println("数组中位置为:"+(b+1)+"; ASCII码为:"+buff[b+1]+"; 对应字符为:"+"\""+(char)buff[b+1]+"\".");
      }
      catch(UnsupportedEncodingException e1){}
    }
    catch(IOException e2){}
  }
}

⌨️ 快捷键说明

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