?? fileprocess.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 + -