2018-05-08 IO InputStream
1009 ワード
read()第1の方法・・・swift
public class FileInputStreamDemo {
public static void main(String[] args) throws IOException{
FileInputStream fis=new FileInputStream("E:\\java\\a.txt");
byte[] b=new byte[1024];
int len=0;
while((len=fis.read(b))!=-1) {
System.out.print(new String(b,0,len));
}fis.close();
}}
public class FileInputStreamDemo {
public static void main(String[] args) throws IOException{
FileInputStream fis=new FileInputStream("E:\\java\\a.txt");
int len=0;
while((len=fis.read())!=-1) {
System.out.print((char)len);
}
/* : 。 read()
while(fis.read()!=-1) {
System.out.print((char)fis.read());
}
*/
fis.close();
}}
![ .JPG](https://upload-images.jianshu.io/upload_images/3820013-0a4bf783bb5e3568.JPG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
read()
···swift