📄 bytereadtest.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 + -