运用JAVA读取txt文件计算机等级考试
文章作者 100test 发表时间 2010:01:01 12:29:44
来源 100Test.Com百考试题网
    
  package com.b.
  import java.io.BufferedReader.
  import java.io.File.
  import java.io.FileNotFoundException.
  import java.io.FileReader.
  import java.io.IOException.
  /**
  */
  public class Utils {
  /**
  * 读取数据
  */
  public String ReadDate() {
  String url = "c:/data.txt".
  String strs = "".
  try {
  FileReader read = new FileReader(new File(url)).
  StringBuffer sb = new StringBuffer().
  char ch[] = new char[1024].
  int d = read.read(ch).
  while(d!=-1){
  String str = new String(ch,0,d).
  sb.append(str).
  d = read.read(ch).
  }