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

📄 fileprocess.java

📁 这是一个huffmanCode算法
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package lab6;import java.io.*;/** * * @author Administrator */public class FileProcess {	/* Construct method */    int[] code = null;    	public FileProcess(){		/* add your code here */        code = new int[128];        for(int i = 0;i < code.length; i++)        {            code[i] = 0;        } //构造一个int型数组,用来装载每个ASCII码出现的Freq。	}	/* Process the file with given file name, and generate the frequency array */	public void processFile(String file){		/* add your code here */       File files = new File(file);		if(!files.exists()){			System.out.println("cannot find the file!");			System.exit(0);		}		BufferedReader input = null;		try{			 input = new BufferedReader(new FileReader(file));			 int read;			 while((read = input.read()) != -1){				 code[read]++;			 }		}		catch(IOException e){			System.out.println("error!");		}//读取文件,建立Freq数组。		return;	}		/* Get the resulting frequency array of all the characters */	public int[] getFreq(){		/* add your code here */    return code;	}	}

⌨️ 快捷键说明

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