b0b1d0c24efb001c1573b62be8af1246
来自「Svm based face detector code」· 代码 · 共 47 行
TXT
47 行
package com.sans.ninemen.io;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* This class contains utility methods to read board position from the input file.
* @author sanshack
*
*/
public class FileReader {
/**
* This method reads the position given in the filename.
* @param filename - input filename
* @return board position in the filename
*/
public String getPosition(String filename) {
File file = new File(filename);
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
String message = null;
try {
fis = new FileInputStream(file);
// Here BufferedInputStream is added for fast reading.
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
// dis.available() returns 0 if the file does not have more lines.
///////////////////////////////////////////////////////////////
message = dis.readLine();
dis.close();
bis.close();
fis.close();
}catch (FileNotFoundException f) {
System.out.println(filename+" is not found");
}catch(IOException i) {
System.out.println("Could not read from "+filename);
}
return message;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?