public class CLCOMP {
public static void main(String[] args) {
String filePath = "D:\\TEMP\\query.txt";
String line [] = {""};
myFile myObj = new myFile();
if ( !myObj.open( filePath ) ) {
System.out.println( filePath + " を open できません" );
return;
}
while ( myObj.get( line ) ) {
System.out.println( line[0] );
}
myObj.close();
}
}
class myFile {
private BufferedReader inFile = null;
public boolean open( String filePath ) {
try {
inFile = new BufferedReader( new FileReader( filePath ) );
}
catch ( Exception e ) {
return false;
}
return true;
}
public boolean get( String buff [] ) {
String line;
try {
line = inFile.readLine();
if ( line == null ) {
return false;
}
buff[0] = line;
}
catch ( Exception e ) {
return false;
}
return true;
}
public void close( ) {
try {
inFile.close();
}
catch ( Exception e ) {
}
return;
}
}
|