count.java

来自「这是一个URL检索的算法」· Java 代码 · 共 91 行

JAVA
91
字号

import java.io.*;
public class count{
public static void main(String []args)
	{	
		   String s=new String();int size=5;
		   int count=0;int hashcode;int hashnum=0;int stringnum=0;
		   count hash=new count();
		   String sbuff[]=new String[size];
		   long start=0;
	try		{
			File f=new File("D:\\download\\temp6.txt");
			FileInputStream fint=new FileInputStream(f);
            BufferedInputStream bint=new BufferedInputStream(fint);
			DataInputStream  in=new DataInputStream (bint);
	   
            System.out.println("parent path"+f.getParent());
		    System.out.println("parent path: "+f.getName());
	        System.out.println("file  length: "+f.length());
	        
		    start=System.currentTimeMillis();
		    while((s=in.readLine())!=null)//&&(count<=21677))
		   	  {
                 count++;		    
		      
			}
				
			in.close();bint.close();fint.close();
		}
		catch(IOException ioe)		{System.out.println(ioe);}
		
		System.out.println("time had "+(System.currentTimeMillis()-start));
		System.out.println("count is "+count);
		System.out.println("stringnum is "+stringnum);
	    System.out.println("hashnum is "+hashnum);
	    
	    
	}


int Hfip(String url,int size)
	{
	  int n=0;
	  byte []b=new byte[4];
	  
		
		int m=n;
		for (int i=0;i<4;i++)
		{
			b[i]=(byte)((m>>8*(3-i))&0xFF);
					
		}
		
		for (int i=0;i<url.length();i++)
		{
			b[i%4]^=url.charAt(i);
					
		}
		
		n=b[0]<<24|b[1]<<16|b[2]<<8|b[3];
		
		
	 if (n>0)	  return n%size;
		  else 
		  {
		  	int tempa=n;long j=1;long a3=0;int t;
	       for(int k=0;k<32;k++,j=(long)Math.pow(2,k))
	        {t=tempa&0x01;
	         a3=a3+t*j;
	          tempa=tempa>>1;
	          
	          }
	          
	        
		  	return (int)(a3%size);
		
			
	        }
	        
	     }






}


		
	

⌨️ 快捷键说明

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