java读txt文件

阅读更多

/* 来于互联网

  * 读取char

  */

  private String readtxt() throws IOException{

  BufferedReader br=new BufferedReader(new FileReader("d:/sql.txt"));

  String str="";

  String r=br.readLine();

  while(r!=null){

  str+=r;

  r=br.readLine();

  }

  return str;

  }

  Java代码

  /*

  * 读取char

  */

  private String readtxt() throws IOException{

  BufferedReader br=new BufferedReader(new FileReader("d:/sql.txt"));

  String str="";

  String r=br.readLine();

  while(r!=null){

  str+=r;

  r=br.readLine();

  }

  return str;

  }

  Java代码

  /*

  * 读取char

  */

  private String readtxt2() throws IOException{

  String str="";

  FileReader fr=new FileReader("d:/sql.txt");

  char[] chars=new char[1024];

  int b=0;

  while((b=fr.read(chars))!=-1){

  str+=String.valueOf(chars);

  }

  return str;

  }

  Java代码

  /*

  * 读取char

  */

  private String readtxt2() throws IOException{

  String str="";

  FileReader fr=new FileReader("d:/sql.txt");

  char[] chars=new char[1024];

  int b=0;

  while((b=fr.read(chars))!=-1){

  str+=String.valueOf(chars);

  }

  return str;

  }

  Java代码

  /*

  * 读取bytes

  */

  private Byte[] readtxt3() throws IOException{

  InputStream input=new FileInputStream("d:/sql.txt");

  byte[] b=new byte[1024];

  ArrayList lsbytes=new ArrayList();

  int n=0;

  while((n=input.read(b))!=-1){

  for(int i=0;i lsbytes=new ArrayList();

  int n=0;

  while((n=input.read(b))!=-1){

  for(int i=0;i 

你可能感兴趣的:(java,txt,java读取txt文件)