File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22<classpath >
33 <classpathentry kind =" src" path =" src" />
44 <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
5- <classpathentry kind =" lib" path =" D:/Program Files/ eclipse/log4j-1.2.17.jar" />
6- <classpathentry kind =" lib" path =" D:/Program Files/ eclipse/lombok.jar" />
5+ <classpathentry kind =" lib" path =" D:/eclipse/log4j-1.2.17.jar" />
6+ <classpathentry kind =" lib" path =" D:/eclipse/lombok.jar" />
77 <classpathentry kind =" output" path =" bin" />
88</classpath >
Original file line number Diff line number Diff line change 1+ package com .chuanzhi .io01 ;
2+
3+ import java .io .FileWriter ;
4+ import java .io .IOException ;
5+
6+ public class FileWriterDemo {
7+ public static void main (String [] args ) throws IOException {
8+ FileWriter fw =new FileWriter ("" );
9+ fw .write ("abcde" );
10+
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ package com .it520 .io01 ;
2+
3+ import java .io .File ;
4+ import java .io .FileInputStream ;
5+ import java .io .InputStream ;
6+
7+ public class FileInputStreamDemo {
8+ public static void main (String [] args ) throws Exception {
9+ //1.创建目标对象(表示数据保存到哪一个文件)
10+ File f1 =new File ("file/stream.txt" );
11+
12+ //2.创建水管
13+ InputStream input =new FileInputStream (f1 );//InputStream和OutputStream不能直接new
14+ //3.具体操作
15+ byte [] b1 =new byte [5 ];//
16+ int len =-1 ;
17+ len =input .read (b1 );
18+ while (len !=-1 ){
19+ String str =new String (b1 ,0 ,len );
20+ System .out .println (str );
21+ }
22+ //4.关闭操作
23+ input .close ();
24+ }
25+
26+ }
Original file line number Diff line number Diff line change 66public class TestFile01 {
77 public static void main (String [] args ) throws IOException {
88 File f1 =new File ("java宝典0" );//创建新的file对象
9+ if (f1 ==null ){
10+ f1 .createNewFile ();
11+ }
912 System .out .println (f1 );
1013 System .out .println (f1 .getAbsolutePath ());
11- if (!f1 .exists ()){
14+ /* if(!f1.exists()){
1215 f1.createNewFile();//这个需要是空括号,执行创建新文件的功能
1316 }else{
1417 f1.delete();
15- }
18+ }*/
1619 }
1720}
Original file line number Diff line number Diff line change 44
55public class ReadObject {
66 public static void main (String [] args ){
7- try {
7+ /* try{
88
99 ObjectInputStream ois=new ObjectInputStream(fis);
1010 }
11- catch (){
11+ // catch(){
1212
13- }
13+ }*/
1414 }
1515}
You can’t perform that action at this time.
0 commit comments