harddiskdriver.java

来自「只是一个简单模拟操作系统」· Java 代码 · 共 73 行

JAVA
73
字号
/* * HardDiskDriver.java * * Created on 2006年3月15日, 下午9:58 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package os.memory.harddisk;/** * * @author Vernkin */import java.io.*;public class HardDiskDriver {    String head = "src/source/";        public static HardDiskDriver hd = new HardDiskDriver();    /** Creates only a new instance of HardDiskDriver */    private HardDiskDriver() {    }        public static HardDiskDriver getInstance(){        return hd;    }        public int[] getData(String name){          //      String sour = head+name+".txt";  //      System.out.println("HDisk Open "+sour);        BufferedReader br =null,br2 = null;        int[] ret = null;        int count=0;        String temp;	try{            br = new BufferedReader(new FileReader(name));            temp = br.readLine();                         while(temp!=null && !temp.equals("")){		count++;		temp = br.readLine();   //            System.out.println(temp);            }             br.close();                        if(count == 0) return null;            ret = new int[count];            count = 0;            br2 = new BufferedReader(new FileReader(name));                        temp = br2.readLine();                         while(temp!=null && !temp.equals("")){		ret[count++] = Integer.parseInt("0"+temp, 2);	//	System.out.println(ret[count-1]);                temp = br2.readLine();            }                      }catch(IOException e){		System.out.println(e.getMessage());                    return ret;            }	        return ret;            }    }

⌨️ 快捷键说明

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