IO
讀寫文件:
字節流——圖片、mp3、影音
字符流——文本
首先介紹字符流:
public static void main(String[] args) throws Exception
{
wt=null;
{
cr = new char[1];
length=rd.read(cr);
StringBuffer();
FileWriter("f:\\a.txt"); //在f盤創建a.txt
catch (Exception e) {
{
//一定要關閉文件流
//..
(Exception e2) {
字節流:
FileInputStream("Sunset.jpg");
output=new FileOutputStream("f:\\a.jpg");
img=new byte[imput.available()];
length=imput.read(img);
//把圖像寫入f:\a.jpg