????File??
????File???? IO ???д????????????????????File???????Щ????????????????????
????File f = new File("d:/test/1.txt");
???????÷????? API
????delete ?????????File?????·??????? ????????????????????????????????????е????????????
?????????
?????????IO???????????????????????????????д?????????
????1. ???????????????????豸?????????н??????
????2. ??????????????????????????y????????????????????д???????????????????????????????????д???????
????InputStream ?? OutputStream (??????[?????])
?????????????????? ?????? ????????????????InputStream?????
int read() // ???? -1 ????????????β??????
int read(byte[] b) //????b.length????????b?в?????????????????
int read(byte[] b??int off??int len)
void close() //?????????????????????????
???????????????????? д????? ???????????????OutputStream?????
void write(int b) //????????д????????
void write(byte[] b) //?????????????д?????????
void write(byte[] b??int off??int len) //
void flush() //????????????????????
void close() //????????
??????????????????????????????????????
???????? ??????      ?????????д??
??????A?????????д?????B?У?
?????????????????????????????A?????????????????????????????B??????????
????FileInputStream ?? FileOutputStream
???????????????????????????????????????FileInputStream??????????????????????·?????????????????????????????????????????FileOutputStream???????????????????????????
????????????????????????飡??????????????????getBytes()????????????顣
???????unicode??????????ASCII????????java?е??????????unicode????
??????????????FileOutputStream???????д??????????????FileInputStream??????
public class FileStreamDemo {
public static void main(String[] args) {
File f = new File("Hello.txt");
//??????????
try {
FileOutputStream out = new FileOutputStream(f);
byte buf[] = "hello??well".getBytes();//?????????
out.write(buf);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
//??????ж?????????????
try {
FileInputStream in = new FileInputStream(f);
byte[] buff = new byte[1024];
int len = in.read(buff);
System.out.println(new String(buff??0??len));
} catch (Exception e) {
e.printStackTrace();
}
}
}