テキストファイルの処理


  内部 static クラス



前述のメソッドをクラスに入れて、クラス経由で呼び出します

  
public static void main(String[] args) {

	String filePath = "D:\\TEMP\\query.txt";
	String line = null;
	BufferedReader inFile = null;

	inFile = myFile.myOpen( filePath );
	if ( inFile == null ) {
		System.out.println( filePath + " を open できません" );
		return;
	}

	try {
		while ( ( line = inFile.readLine() ) != null) {
			System.out.println( line );
		}

		inFile.close();

	}
	catch ( Exception e ) {
		System.out.println( e.getMessage() );
	}

}


private static class myFile {
	public static BufferedReader myOpen( String filePath ) {

		BufferedReader inFile = null;

		try {
			inFile = new BufferedReader( new FileReader( filePath ) );
		}
		catch ( Exception e ) {
			return null;
		}

		return inFile;
	}
}
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ