📄 temp2.java
字号:
import java.io.*;
public class temp2
{
public static void main(String []args)
{
int length=1;
char cbuf[]=new char[length];
temp2 Temp2=new temp2();
char c2=Temp2.test(1,10);
int n2=(int)c2;
System.out.println(n2);
c2=Temp2.test(2,6);
c2=Temp2.test(2,5);
c2=Temp2.test(2,0);
cbuf=Temp2.read("D:\\download\\hashtempFile3.txt",2,length);
for(int i=0;i<length;i++)
{System.out.print("this is "+cbuf[i]+" ");}
System.out.println();
long start=System.currentTimeMillis();
try
{
RandomAccessFile f3=new RandomAccessFile("D:\\download\\hashtempFile1.txt","rw");
f3.seek((long)Math.pow(2,28));
char tt=f3.readChar();
f3.close();
}
catch(IOException e) {System.out.println(e);}
System.out.println("time had "+(System.currentTimeMillis()-start));
}
char[] read(String s,int offset,int length)
{
char buf[]=new char[length];
int temp;
try{
RandomAccessFile f=new RandomAccessFile(s,"rw");
temp=offset*2;
for(int i=0;i<length;i++)
{ f.seek(temp);
buf[i]=f.readChar();
temp=temp+2;
}
f.close();
}
catch(IOException e) {System.out.println(e);}
return buf;
}//end test
char test(int m1,int m2)
{
char buf=0,temp;
try{
RandomAccessFile f=new RandomAccessFile("D:\\download\\hashtempFile3.txt","rw");
//RandomAccessFile f1=new RandomAccessFile("D:\\download\\hashtempFile2.txt","rw");
System.out.println("this is "+f.length());
f.seek(m1*2);
buf=f.readChar();
temp=buf;
if (((temp>>m2)&0x01)==1) System.out.println("this has had");
else {System.out.println("not have");
buf=(char)(buf|(1<<m2));
f.seek(m1*2);
f.writeChar(buf);
}//endif
f.close();
}
catch(IOException e) {System.out.println(e);}
return buf;
}
}//end class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -