index2.java

来自「利用开源词典star-dict编写的一个小词典程序,使用方法仿照金山词霸」· Java 代码 · 共 53 行

JAVA
53
字号
import java.io.*;

//用以生成索引的索引!

public class Index2 {

	public static void main(String[] args) throws Exception
	{
		 File f2 = new File ("stardict.idx");
		 RandomAccessFile idx=new RandomAccessFile(f2,"r");
		 
		 File f1 = new File ("idxidx.idx");
		 RandomAccessFile Fout=new RandomAccessFile(f1,"rw");
		 
		 byte []attempt =new byte [50];
		 int i;
		 int place = 0;
		 byte az = 65;
		 while(true)
		{
			i = -1;
			do
			{
				i++;
				attempt[i] = idx.readByte();	
			}while(attempt[i] > 0 );
			
			idx.skipBytes(8);
			
			if(attempt[0] ==az ||attempt[0] ==(az+32))
			{
				az++;
				//System.out.println(place-2);
				Fout.writeLong(place-2);
				
				
			}
			place++;
			
			if(idx.getFilePointer()>=idx.length())
			{
				
			break;
			}
			
		
		}
		Fout.writeLong(place-2);
		
		Fout.close();
	}	
}

⌨️ 快捷键说明

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