From 718187c9f1c689d3678fecd49e3c49222bd0c2e8 Mon Sep 17 00:00:00 2001 From: hh351260 <86143144+hh351260@users.noreply.github.com> Date: Sat, 19 Jun 2021 16:06:07 +0800 Subject: [PATCH] Add files via upload --- Test1.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Test1.java diff --git a/Test1.java b/Test1.java new file mode 100644 index 0000000..8ac0b8b --- /dev/null +++ b/Test1.java @@ -0,0 +1,29 @@ +package FanShe; + +import java.io.*; + +public class Test1 { + public static void main(String[] args) throws IOException { + FileInputStream fileInputStream=null; + try { + fileInputStream=new FileInputStream("F:\\考试.74\\PaiXu.java"); + // 获取文件目录 + byte[]bytes=new byte[300]; + int len=fileInputStream.read(bytes); + System.out.println(len); + String str=new String(bytes,0,len,"utf-8"); + System.out.println(str); + for (int a:bytes){ + // System.out.println((char)a); + } + int a=fileInputStream.read(); + System.out.println(a); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + }finally { + fileInputStream.close(); + } + } +}