Skip to content

Commit b3cd2b0

Browse files
author
crazy
committed
13
1 parent dcef6c4 commit b3cd2b0

5 files changed

Lines changed: 48 additions & 7 deletions

File tree

JavaBase/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

JavaBase/src/com/xinan/io/TestFile01.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
public 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
}

JavaBase/src/com/xinan/io01/ReadObject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public 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
}

0 commit comments

Comments
 (0)