ReadFile 读文件示例代码!

/**
*
*/
package com.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
* 类 名 称:com.test.ReadFile
* 创建日期: 2007-11-25
* 文件名称:ReadFile.java
* 项目声明:tangchaonioa
* 版权信息:和利时信息技术有限公司 工程部
* 编 写 人:maliang
* 版 本 号:v1.0
* 功能描述:
* 修改历史:
*
*/

/**
* @author maliang
*
*/
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.StringTokenizer;


public class ReadFile {
public static void main(String[] args) {
StringTokenizer token = null;
String getLine = null;
BufferedReader bufRead = null;
File file = new File("d:/oracleip.txt");

try {
bufRead = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
System.out.println(bufRead.readLine());
/*while (bufRead.readLine().equals("-1")) {
getLine = bufRead.readLine();

if (getLine != null) {
token = new StringTokenizer(getLine, ",");

while (token.hasMoreElements()) {
System.out.println(token.nextToken());
}
} else {
break;
}
}*/
getLine = bufRead.readLine();

if (getLine != null) {
token = new StringTokenizer(getLine, ",");

while (token.hasMoreElements()) {
System.out.println(token.nextToken());
}
}
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
}

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8190463/viewspace-984638/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/8190463/viewspace-984638/

你可能感兴趣的:(ReadFile 读文件示例代码!)