您的位置:首页 > 其它

185_08_IO流_FileInputStream_05_byte数组转换成字符串

2017-04-30 17:53 246 查看
package TestIO;
import java.io.*;

public class Test01 {
public static void main(String[] args) throws Exception  {
////内容是:abcdefg
String filepath= "C:/中国电视台直播源.txt";
//创建流
FileInputStream  fis= new FileInputStream(filepath);
//创建数组
byte[] bytes = new byte[1024];
//		  while(true){
//        	 int temp = fis.read(bytes);
//        	 if(temp==-1) break;
//        	 System.out.println(new String(bytes,0,temp));
//		  }
//升级循环
int temp = 0;
while((temp = fis.read(bytes)) != -1){
System.out.print(new String(bytes,0,temp));
}
fis.close();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: