设为首页 加入收藏

TOP

运用JAVA读取txt文件
2014-11-17 18:10:33 】 浏览:1513
Tags:运用 JAVA 读取 txt 文件

  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);


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Java获得文件编码格式 下一篇javaSwing组件大全超牛的例子

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目