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T+H05MYNQzB/ReAAAAAElFTkSuQmCC" alt="" />
--------------------------------------FileInputOutputStream(字节流)-----------------
package IOTest; import java.io.*;
public class FileInputOutputStream {
public static void main(String[] args)throws IOException {
FileOutputStream fos;
fos=new FileOutputStream(".\\test.txt"); //打开文件输出流
byte[] array={1,3,5,7,9,11,13,15,17,19};
for(int i=0;i<array.length ;i++)
fos.write(array[i]); //写数据到文件输出流,也就是写入文件
fos.close(); //关闭文件输出流,即关闭文件
FileInputStream fis;
fis=new FileInputStream(".\\test.txt"); //打开文件输入流
int value;
while((value=fis.read())!=-1) //从文件输入流读数据,也就是从文件读数据
System.out.print(value+" ");
fis.close(); //关闭文件输入流,即关闭文件
}
}
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVoAAACECAIAAABecHTKAAAOZ0lEQVR4nO2c2XMcxR3H++/BRUFRvKzwQ6q0IslDilQqqSIJUBSFVyzGkg1lykkB4RRJOFZIsuQ4a8t2ubBBsJZjayXZDoJgsLFltBKSFnltI/nQYVny6rYQpvMwvbPT1+zM7DGL+X7q9zDb278+ft39ne7ZkQillFJ6yyfSAICygUAOAAAGZSoHPRlKGQsAfuaUoxxACwDwhbKTA2gBAH5RXnIALQDAR8pLDtJQBAD8o+zkIA1FAMAnylEO0lAEAPygTOUAAFB6IAcAAAbkAADAgBwAABiQAwAAg4yNL1MAAKCUjI0vQxEAANSUA4gCAICTAxgM9nM2yAEMBmMGOYDBYMwgBzAYjFlWDk6fHYKdPjvk99McAHyDjI0vfzc2ceZc8sy55HdjEzAjFH6PCwA+QEYvT/b2jYxenoRZrbdvxO+hAaDUkL6B82NXJmGy9Q2c93t0ACgppH/wwpVr12Gy9Q9e8Ht0ACgp5Nr4NExn3wxf8nuAACgdZHziBkxnQ9+O+j1AAJQOMjk1I9h/ey//8sWTVS9o7Tcvf9E7PCE73nmWHBnze4AAKB1k6vqsYA9s/d9Dobd/u+EtnT1U/c4vtn0mO955NpK6rAvcsfZO8/roxz3Z9MPxog4YAM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SMn4wcxHO8leiwjGyfIAfFBnLwk+MnIwcFB3IAAGAwOdgDAPjZg90BAIABOQAAMCAHAAAG5AAAwIAcAAAYkAMAAEMtB6n6ClcvhLH88vvxbrwIqajP/XaV/Fdozvz46ly9TGITDbeBsvHyFkPnBToNk7ZA75HXtZDmMSigGMhyEA8RUlFfH/I8PkYBDqZJqr7CzRTVluGknVyjnDpR22h4C5QzL8cxtCnQa3gd9st5ELUFeh0UUCxEOeD+14fHwVH9ob6KAsiBw2UjTbVUfYVDEdFFw1ugHHs5jaFNgd7C67SFjgVLW6DXQQHFQ/fswLscOJ+FecuB4xuKXJPT5ZbNrcnuLVA5vNxHpmBy4KyFHm7lSjnIZ1BA4SmYHFgOgU7nYD6n5UwbHdbFT1/XJ/4SyYGHGNoUmF94bfvlIvI2BeY5KKDwFH53YIyr69tSPORyEbi9QVmehFXUx905l3p34D6GTvb2hSrQ2ylfWWA+gwIKTxHkII9Tq4sa89sKuzymllwOXPcvd4Eud+L6Aj1G3lmXoQa+UhQ58HQGdHfP8bJd5b3dNNAHOSjY6mV42kyp8nuNfMGenoLiUQQ58DRf3O2O8/lRyjij5vkYzNFX3go0v3cVQwfPJgtSoPfI27bQy6CAwiPKgfTuiqNZxL+h4nRUOS+378i4FBxvT+lsouEtUDZe3mLotEC37wup+5Vn5G1imO/7J6Ag4CVlAAADcgAAYEAOAAAMyAEAgAE5AAAwIAcAAAbkAADAgBwAABiQAwAAA3IAAGBADgAADMgBAIABOQAAMCAHAAAG5AAAwIAcAAAYkAMAAANyAABgQA4AAAzIAQCAATkAADAgBwAABuQAAMCAHAAAGJADAAADcgAAYEAOAAAMyAEAgAE5AAAwIAcAAAbkAADAgBwAABiQAwAAA3IAAGBADgAADMgBAIABOQAAMCAHAAAG5AAAwIAcAAAYkAMAAANyAABgQA4AAAzIAQCAATkAADAgBwAABuQAAMCAHAAAGJADAADj/9BiUghWoTfHAAAAAElFTkSuQmCC" alt="" />
-----------------------------------------FileReaderWriter(字符流)-----------------------
package IOTest; import java.io.*;
public class FileReaderWriterStream {
public static void main(String[] args)throws IOException {
FileWriter fw;
fw=new FileWriter(".\\filestream.txt"); //打开文件输出流
char array[]={'文','本','输','入','输','出','示','例','。'};
for(int i=0;i<array.length ;i++)
fw.write(array[i]); //写数据到文件输出流,也就是写入文件
fw.close(); //关闭文件输出流,即关闭文件
FileReader fr;
fr=new FileReader(".\\filestream.txt"); //打开文件输入流
int value;
while((value=fr.read())!=-1) //从文件输入流读数据,也就是从文件读数据
System.out.print((char)value);
fr.close(); //关闭文件输入流,即关闭文件
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKsAAABYCAIAAAAFjJD5AAAJS0lEQVR4nO2a33NbxRXH9+8hk4Hpm0redM2U1z6VEjIZBq4RYNkmk0zaaWlDS9MWisCWpdRV7DjjIT9MFWeCr+XCoDC4JCRhrJjIwlHcKonxj7iSZVmy7Chi+7D35/66V7IdY3a/sw/37j3n7Nmzn9175QTcnVu7O7eWuzefL6xg7anW4edfPT6Rrx358+irv/noQOfAz1+OPvPLd6GhA6//5anWYcLx1vt+APzdKes2eJEIvlUt9YEfvP5xQy6BQMCcQiAQMG/RI6pL7t48ZOjch5chhFcv/GHh5tuoXbt4DEI4dO5Tqn0xFY/FU0V0k0smc6zAj0kAEXB/drGwXMLaky+dP9j+zkS+xnJ+sfNvT750HvO62aUAf/gmEW2b2s0uBbSNNOplhwAJdbLs788usopwuv9zCOFCZnh86K3xobfGh47dmfwQQjg4+BnVPpeM7fiq26UT8N3c0nJxFWt7Dw6qh96byNeORy+/+V7iyJ+Gg2+ee/nIwP5g7ytH+yGErxx+f+/BQadXussP2j7GQ6E22aUAQ6bNZJcC2rRLbc7+b8J+vUPp+sbdHV2bQYA/PElLwN4wCAKBAMf4u7klsnbX794+/eXI6avawFeJ63P3IIS9/dfMpyf7ktSKO84Am3LJmC7jaTEVjyVTqXgsFkvmcsmYjRzzzsVLv3daUAmYX8ivlMpY2/NC32tHP5jI1wrFt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CG8AAIQxnImHb66cILwBAJDCuL1VWTn9EOENAIAUxt/eP7HwypcJbwAApDB23ntpvvIg4Q0AgBTG/ge+ev+BLxHeAABIYXxzav3f9j9AeAMAIIXxjYNjn7v/i4Q3AABSGM898hnCGwAAQYzF//7wvn//AuENAIAUxkc++i+fuu/zhDcAAFIYH3th9ROf/hzhDQCAFMZnTrbvufc+whsAACmMe+//1j2f/CzhDQCAFMahr37o4//6KcIbAAApjHvu3ffxe+4lvAEAkIL/zxsAAGEIbwAAhCG8AQAQhvAGAEAYwhsAAGEIbwAAhCG8AQAQhvAGAEAYw5l4+ObKCcIbAAApjNtblZXTDxHeAABIYfzt/RMLr3yZ8AYAQApj572X5isPEt4AAEhhHD9+/Pjx44Q3AABSsNscAABhjJ9Xl4+cXya8AQCQwlhstye2GHkDACCG8fZOe/7vhDcAAGIYK+32PGveAADIYXztuV//x2+PEt4AAEhhfOXwr/7zRcIbAAAxjJFna0+OzhHeAABIYbg5TXgDACAFf2ENAABh+AtrAAAIQ3gDACAM4Q0AgDCENwAAwhDeAAAIQ3gDACAM4Q0AgDCENwAAwhjOxMM3V04Q3gAASGHc3qqsnH6I8AYAQArj1KlTY2NjhDcAAFKw5g0AgDDGG2dee+PMa4Q3AABSGNX1nYX3bxPeAABI8f+CnddqQD+euQAAAABJRU5ErkJggg==" alt="" />
追加文本
package IOTest; import java.io.*;
public class FileAppendStream {
public static void main(String[] args)throws IOException {
String str="Welcom to Java!";
FileWriter fw;
fw=new FileWriter(".\\filestream.txt",true); //打开输出流
fw.write(str); //写字符串到文件输出流
fw.close(); //关闭文件输出流
FileReader fr;
fr=new FileReader(".\\filestream.txt"); //打开输入流
int value;
while((value=fr.read())!=-1) //从文件输入流读数据
System.out.print((char)value);
fr.close(); //关闭文件输入流
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAT8AAABsCAIAAACTqSIRAAAO50lEQVR4nO2c/XMTxxnH9+8Jk0kmk1+k8ENnLKftD510Ou1M2i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LH1HJ5AOiL/j/hbL+Y+RRsfzoujOTC9suepi37YL853RbLhpCuEampkSzdKuZ2pKsZ6YfC3ha2b8Ow05SbMPTEcnkA6J02eg0nQZvzYy/Rm0+Rapsr1b4Nw6bte6hMC5sWECn1PwYAHELav+FcvKZxsQrRKzZY4fRqGLWY27fUlw9rzm/YqDY+BoDDw/YJZwAA0BdELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAOAU0QsAgFNELwAAThG9AAA4RfQCAODU/wGpE410CnqsQQAAAABJRU5ErkJggg==" alt="" />
-------------------------------------------BuffereReaderWriter(缓存字符流)-----------------------------
带缓存的流
package IOTest; import java.io.*;
public class BuffereStream {
public static void main(String[] args) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
OutputStream os=new FileOutputStream(".\\buffer.bin");//打开字节文件写
OutputStreamWriter fout = new OutputStreamWriter(os);//字节流转换字符流
BufferedWriter bout=new BufferedWriter(fout);//字符流转换为缓冲流
String str;
while(true){
str=br.readLine(); //从键盘读一行字符
if(str.equals("end"))
break;
bout.write(str); //将读入的字符写入文件中
bout.newLine(); //写行分隔符到文件中
}
bout.close(); //关闭文件
InputStream is=new FileInputStream(".\\buffer.bin");//打开字节文件读
InputStreamReader fin = new InputStreamReader(is);//字节流转换字符流
BufferedReader bin=new BufferedReader(fin);//字符流转换为缓冲流
while((str=bin.readLine())!=null)//从文件中读一行字符
System.out.println(str); //显示
bin.close();
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKcAAAEtCAIAAADiKOexAAANe0lEQVR4nO2dX2wcxR3HR6JVVZWqL1WlPvWlElUoCqLhwcY4rQw0kVpCaCFAgx1CfIYEJ02wU1LhmBZKnEJySXAhJS5J2lQBk0LUhHUqrLpEIUSqU58tRap0be9QLdrYtc8lNEWYavuwd/vvZmdmb/3n4u/3o3nY253ZnZvPzG/mzrqxOHn+PSa0JOa9Bkxzn2gdMdE6YqJ1xCR6jw8woSXx7nuXmdASrSMmWkdMwuoftPoHFTmcDEwLKQnbtm3btsrEOyet/kGblJpi5N2phZGEK7hc+Xw3ddWxYMTLrVN5FAtDvMS6zYEezYK1TuVqrP7B4fzUFZ1oPTZA1v/016nlnWe/uf3tqHTHk+/kLl6ecwXzAJD1uq2nV6SevaP5mai0omXXN7adnnMF84DVPzicL0hT2wMb3eOH7+t0j9vXtkYVmZdkan3Jxv7vrntyaGI6Kt3T8vSSjf1zriBAvmeZaBuIVeThEtqTLgrr61e3D+cL77y27nD71Yfbr/7V1qv/+NsHhvOFjY1b5t10JdZv2GDd1fzU0MR0VPPd0/L0DRss6aV8zzJRIqaUeFRmXXsQQmG96e7Hh/OFIz/47McXX3HSK9s+PZwvPHhve1SRUzsbik2zdN+parN+fcvx763fMTQxvbWrb/3jxxo3H76z+YXb7nvWzdD4yM7rW45LRYhlPXnv5Sx6T2LdLg1x6SU/Cuvf+dYTw/nCnqZPZX75GSd1r71qOF9Ydee2SOWu7Jdbm16uMuuL1/Wu2fSMYqyv3bxr8bre0Ml8zzKf8lmnAut2hN0o5bZtW/2DmVxBmm5Z+uNMrjD8+gM77/7EzlWf3LnqqlN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I7wktZccU6mw93BM7gTl+rmiwhEtQuEAifSAz7yjIt6cubTk0b8AIFvx6xeWPkkzKHvFL8QLJVjdoq/Cb6yfsz1/iWI3E6rvnadnTenHc+0G2MxQuP4STeFc1u0m74peoaFwpmmWDw7KpYOuyJV5kas69Zppmj01D4BzSZSlln4uDw4c1A/DyZNQuA8bDYUbGhoqvXvnidwhJXJDQ0Px2QrAOQECB8CZQEPhPotGfLYCAAAA0UEEVAAAAIMJFA4AAMBgAoUDAAAwmEDhAAAADCZQOAAAAIOJhsLNzs7Ozs6WyxXyg+M48VkJAAAA6PI/0FOttpjAuVQAAAAASUVORK5CYII=" alt="" />
InputStreamReader 是字节流通向字符流的桥梁。
---------------------------------------BufferReaderWriter------------------------------------------------------------------
带缓存的流
package IOTest; import java.io.*;
public class BuffereStream_1 {
public static void main(String[] args) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
FileWriter fout = new FileWriter(".\\buffer.txt");//打开文本文件写
BufferedWriter bout=new BufferedWriter(fout);//字符流转换为缓冲流
String str;
while(true){
str=br.readLine(); //从键盘读一行字符
if(str.equals("end"))
break;
bout.write(str); //将读入的字符写入文件中
bout.newLine(); //写行分隔符到文件中
}
bout.close(); //关闭文件
FileReader fin=new FileReader(".\\buffer.txt");//打开文本文件读
BufferedReader bin=new BufferedReader(fin);//字符流转换为缓冲流
while((str=bin.readLine())!=null)//从文件中读一行字符
System.out.println(str); //显示
bin.close();
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAEMCAIAAACtHAgZAAAM9UlEQVR4nO2dX2wUxx3HV0qrqipVX6pKfepLpVTQiIiSh3Mc08okNVIbQtoASR0MBK8JBFOD7UKFcVpSsJvAGXCBBjfglIrg0AQVsqaKVReUEKQ69dkSUqVrexfVaotd+1xIaRRTXR/2bm9ud/7t7p19P9/3o5HYPzO7O/PZ38zuwg3GB3+/g0Q0GdbAkCtJcnszI81hMtIeLI8/e6M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IGJUGDkqBBSdCgJGhQEjQoCRqUBA1KggYlQYOSoEFJ0KAkaFASNCgJGpQEDUqCBiVBg5KgQUnQoCRoUBI0KAkalAQNSoIGJUGDkqBBSdCgJGhQEjQoCRqUBA1KggYlQYOSoEFJ0KAkaFASNCgJGpQEDUqCBiVBg5KgQUnQoCRoUBI0KAkalAQNSoIGJUGDkqBBSdCgJGhQEjQoCRqUBA1KggYlQYOSoEFJ0KAkaFASNCgJGpQEDUqCBiVBg5KgQUnQoCRoUBI0KAkalAQNSoIGJUGDkqBBSdCgJGhQEjQoCRr/B48VXMoD34I/AAAAAElFTkSuQmCC" alt="" />
-----------------------------------------------DataInputOutputStream----------------------------------------
输入任意类型数据
package IOTest; import java.io.*;
public class DataInputOutputStream {
public static void main(String[] args) throws IOException{
char c='A';
int i=3721;
long l=123456;
float f=3.14f;
double d=3.1415926535;
String str="基本类型数据输入输出示例";
DataOutputStream output=new DataOutputStream(new FileOutputStream(".\\datastream.dat"));
output.writeChar(c);
output.writeInt(i);
output.writeLong(l);
output.writeFloat(f);
output.writeDouble(d);
output.writeUTF(str);
output.close();
DataInputStream input=new DataInputStream(new FileInputStream(".\\datastream.dat"));
char cc=input.readChar();
int ii=input.readInt();
long ll=input.readLong();
float ff=input.readFloat();
double dd=input.readDouble();
String sstr=input.readUTF();
input.close();
System.out.println(cc+"\n"+ii+"\n"+ll+"\n"+ff+"\n"+dd+"\n"+sstr);
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAADTCAIAAAA55KknAAAQtElEQVR4nO2d7XMURR7H+++RsrQs3yTy4qqy8e5eXHl1dVfl3allWbJxRRLQwuKu1PMx3p0PiRASjlsIUJSg6AIHbMLDGT1REIJZIkkMC5jwkAdCwiYkBIzY92J2Z3v6aXpms7tJ8/3Ur1KTnv79uqf7O709u9vbZHDopmvJI50wmDVGWHHDYDYZxA2z1iBumLUGccOstby4j5/sgR0/2UOBLZDBoZs/DA6fONV34lTfD4PDMKcpy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BGvfGs+m2qatvYbCIC9I41Kt67b94dk+qid8P3eAt/nJOP/n6+q6vDHj0D5Y0r5qqq+0V0BwO4A3QOwHuD7nGT8frzf0rHeiw0AAODDAt/nJKPvAQAAgG0C3+cEvgcAALAHwPc5ge8BAADsAfB9TpS/AAAAgH3grY253yhvPQEAAAAAbJyMvr++vr6+vh6NTHJjPp+vd5YAAAAAyEN23zu2fXl5+eef/3ddx9twHPvy8vL29vb8/Hw0Hq13ogAAAADITEbfX11d2fb8uf/3y8vAdR1vY7Fwn/t/39zcmKbZ7XaHw+F65woAeI8M2uWS0dudfgB4n2T0/cXFxdz/HjzHsV3XcV1nsXAXC7fT6bRarVar1el0qKaP2rGiKEpR046VY+1xuVyeFZXiWY5jAADsOT2jVG4P4moM2uWEGnH99AyhWCoA4N2T0ffdbnf1PXjzuWPPBeX/8/Ly/PRE+v5RO17J/RG+BztJz/C/roM1QlAqaoLzUNiWqh3En4N2OaK3sA49DRHJgpHzTNrbM+JHWivB8UdCnRjyZKXrZ6X38HEg8H3ykwbISMwjWs9gMjHeZRTu+oQbH2Qho+87nc7vfzzH/2m1WnLDs+JK8nzZL/k+fGbYCvHDbXkyYNMwcV/PWC1Cy0G7HHqiFKxUvm7odUnKLvvLH7OD7Y2rQ05D7l8YPWKeKfZ6nW15gR20y+KBMcedKHO2ZnQ/XDfl9mB19ntGuA3WTvw/Dc733L3IPn1F3fggM/8Bf+2BCQNI6DsAAAAASUVORK5CYII=" alt="" />
----------------------------------------------ObjectStream------------------------------------------------------
将类对象写入文件(必须实现序列化接口)
package IOTest;
import java.io.*;
public class ObjectStream{
public static void main(String arg[])throws Exception{
Employee e1 = new Employee(1001,"Wang",5678.50);
FileOutputStream fos = new FileOutputStream(".\\object.dat");
ObjectOutputStream out = new ObjectOutputStream(fos); //创建输出对象流
out.writeObject(e1); //写入对象
out.close();
FileInputStream fis = new FileInputStream(".\\object.dat");
ObjectInputStream in = new ObjectInputStream(fis); //创建输入对象流
Employee e2 = (Employee)in.readObject(); //读取对象
System.out.println("Id: "+e2.id);
System.out.println("Name: "+e2.name);
System.out.println("Salary: "+e2.salary);
in.close();
}
}
class Employee implements Serializable{ //必须实现Serializable接口
int id;
String name;
double salary;
Employee(int i,String n,double s)
{
id=i;
name=n;
salary=s;
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAAB7CAIAAACgrWihAAAOJklEQVR4nO2d7XMbxR3H9+8hw8AwvLHIi85Ypu2LDp1OO0NbYBiGnBEhdgITJu0AhQKmLQ8StmOnqRInmQwJGBSnic92kmIohgQIRHmQHUeJqySOHceRIstWZMeY7YvT3e3jPUirWBK/z/wmc97d3+7e7vd29+5WF4RNLk/dtuzs6MS1qVkwmZ0dncCABGQdkZJKnE9NTd8Ek1nifGoV+6zKEUtqbPzy9Zk0Y/85eeXnL480vSS1X7365cnRad6x/mxs/PIq9lmVI5bUePLKzI0MYw9t/u8j2ju/Xve2zB5pfvdnWz7nHevPxpNXZA16pG/AOj78ybAdflCvTA9WHWJJXZyYvDF7i7EHW4799unXT6WXZfZoc9uDLcd4x7tp34Ub0fpDvlxCJlYIxpgPJO3ixKSsQftjRzDGV8f+HT/SFj/Sdvpo27XxPozxwIGhyvdmVSCW1ERqavZmlrEH1uu/W/fGqfSyLK9Hm9seWK/zjrM3s99HGpHJ+oOCBKrs+0gjWn/Yl0soFDLqHwqFZm9mjQMyhLeJ1JSsEQ70fooxPnO07ceFc4adO/YGxvjgx0dkLtl4LGoQi2f9dV81IpZU6sp0OjPH2P3NfX989q1T6eUX/zbw7EsfP7Fp92/WdT/8h3esHJ547u/3N/dxjucijQg1dsTtP1sOcpmrsvj7jei5w75cLAFhc3Ayjo0ooUvqyrSsQT/84DOM8YkDr18//aZh3xx8DWPc++ExYfpsPGYrKTU8XPvrfrGkrk7OZG7lGLvv6Y+ebH3bYZR6atO79z39EeN1uj2IGjtPc7lVyE63B9GGfr9epKoMjEBZ+quTM7JG2NPzOcb4+ljfSO9fR3r/OtL72s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HpMp451VlG/YIuPfJwu3GgnfNLMKvjojyK7EatYOvL7eUrIrqlpS0+zy+E+K2LNgZen3iXk9bZ3y84yvjlGtTUh43Gsv37bnk77EatYZHSbldr5JtuGS0wFnmVexLO5rYHOD8WbySvmUl6UtvihJ+WNIM8Ty2/wQlhYn+505dvg2XDGTDHLyKRZGf1hPt5FXx9WL5AtHY3OK4PZ6vEH0C3itST3uz/N7xWecuvaZE8nGf+LhdJZIPuZJRyi9te986pkcbQaWsGrAnRrxe5n79WEI1ao/SHiIwb+Wl23BNhJKSezkpkP4FjOrLmd4QzW9u4b+mzHQ9K7LSbmuqd+3pgRKfSzH/04bzZCSdoGRezi1qr7SUX8mkIIQ/uHAOkCXyq47a3plVmqTIa89pGy6ZXiApmZdLNyQjAaRpmjBJqV8vtny5/8tIcisn6XemfMEmK2b7qXs1ag0fDxFIBHdZZgS7DZdBuE2Y9nK9sh1041dSzo8l6Tpy/4OAuN/pCZ2rCr1J3lM1aouafMdXT7fc9UcNSqq2Vxr1Ty1JyppRQE/VTC1JCqgJQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBiQFKAYkBSgGJAUoBi/g92F0REOybPPAAAAABJRU5ErkJggg==" alt="" />
不希望序列化的可以加transient修饰。
-----------------------------------------------------LineNumberReader----------------------------------------------------
获取带行号的内容
package IOTest;
import java.io.*;
public class AddlineNo {
public static void main(String[] args) {
String str=null;
try{
FileReader file=new FileReader(".\\buffer.txt");
LineNumberReader in=new LineNumberReader(file);
while((str=in.readLine())!=null)
System.out.println(in.getLineNumber()+":"+str);
in.close();
}catch(IOException e){
System.out.println("文件打不开或读文件错误!");
}
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAACkCAIAAAA4zcbSAAAKEklEQVR4nO2dX2wcRxnARyoIIYJ4QUg88YJUlFClCunDX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ym4KBxfjXAd92Cww6zOl0r2gCTo+46tOhB49CgcWjQODRoHBo0Dg0ahwaNQ4PGoUHj0KBxaNA4NGgcGjQODRqHBo1Dg8ahQePQoHFo0Dg0aBya/wP9J8YOKtACowAAAABJRU5ErkJggg==" alt="" />
两个案例:
--------------------------------------------文件流实现拷贝图片----------------------------------------
package cn.itcast.output; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; /*
需求: 拷贝一张图片。
*/
public class CopyImage { public static void main(String[] args) throws IOException {
//找到目标文件
File inFile = new File("F:\\美女\\1.jpg");
File destFile = new File("E:\\1.jpg");
//建立数据的输入输出通道
FileInputStream fileInputStream = new FileInputStream(inFile);
FileOutputStream fileOutputStream = new FileOutputStream(destFile); //追加数据.... //每新创建一个FileOutputStream的时候,默认情况下FileOutputStream 的指针是指向了文件的开始的位置。 每写出一次,指向都会出现相应移动。
//建立缓冲数据,边读边写
byte[] buf = new byte[1024];
int length = 0 ;
while((length = fileInputStream.read(buf))!=-1){ //最后一次只剩下了824个字节
fileOutputStream.write(buf,0,length); //写出很多次数据,所以就必须要追加。
}
//关闭资源 原则: 先开后关,后开先关。
fileOutputStream.close();
fileInputStream.close();
} }
--------------------------------------------缓冲流实现拷贝图片----------------------------------------
package cn.itcast.buffered; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; /*
练习: 使用缓冲输入输出字节流拷贝一个图片。 */
public class CopyImage { public static void main(String[] args) throws IOException {
//找到目标文件
File inFile = new File("F:\\美女\\1.jpg");
File outFile = new File("E:\\1.jpg");
//建立数据输入输出通道
FileInputStream fileInputStream = new FileInputStream(inFile);
FileOutputStream fileOutputStream = new FileOutputStream(outFile);
//建立缓冲输入输出流
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
//边读边写
int content = 0;
// int length = bufferedInputStream.read(buf); 如果传入了缓冲数组,内容是存储到缓冲数组中,返回值是存储到缓冲数组中的字节个数。
while((content = bufferedInputStream.read())!=-1){ // 如果使用read方法没有传入缓冲数组,那么返回值是读取到的内容。
bufferedOutputStream.write(content);
// bufferedOutputStream.flush(); //一般带缓冲的不刷新,否则缓冲没意义
}
//关闭资源
bufferedInputStream.close();
bufferedOutputStream.close(); } }
注意:
如果传入了缓冲数组,内容是存储到缓冲数组中,返回值是存储到缓冲数组中的字节个数。
如果使用read方法没有传入缓冲数组,那么返回值是读取到的内容。
不加缓存数组:
//边读边写
int content = 0;
while((content = bufferedInputStream.read())!=-1){ // 如果使用read方法没有传入缓冲数组,那么返回值是读取到的内容。
bufferedOutputStream.write(content);
// bufferedOutputStream.flush(); //一般带缓冲的不刷新,否则缓冲没意义
}
加缓存数组
//建立缓冲数据,边读边写
byte[] buf = new byte[1024];
int length = 0 ;
while((length = fileInputStream.read(buf))!=-1){ //最后一次只剩下了824个字节
fileOutputStream.write(buf,0,length); //写出很多次数据,所以就必须要追加,读取buf数组中从0开始的length长度的字节数。
}
补充:org.apache.commons.io.IOUtils可以简单的将一个inputStream的文件读取到另一个outputStream,实现文件的拷贝,例如:
只用传两个参数,第一个传递InputStream,第二个传递OutputStream
package cn.qlq.craw.Jsoup; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection; import org.apache.commons.io.IOUtils; public class IOutilsDownloadFile {
public static void main(String[] args) throws IOException {
String url = "http://qiaoliqiang.cn/fileDown/zfb.bmp";
URL url1 = new URL(url);
URLConnection conn = url1.openConnection();
InputStream inputStream = conn.getInputStream();
String path = "C:\\Users\\liqiang\\Desktop\\test.bmp";
OutputStream outputStream = new FileOutputStream(path);
// 利用IOutiks拷贝文件,简单快捷
IOUtils.copy(inputStream, outputStream);
}
}
----------------------字符流和字节流的区别-------------------
1. 什么是流
Java中的流是对字节序列的抽象,我们可以想象有一个水管,只不过现在流动在水管中的不再是水,而是字节序列。和水流一样,Java中的流也具有一个“流动的方向”,通常可以从中读入一个字节序列的对象被称为输入流;能够向其写入一个字节序列的对象被称为输出流。
2. 字节流
Java中的字节流处理的最基本单位为单个字节,它通常用来处理二进制数据。Java中最基本的两个字节流类是InputStream和OutputStream,它们分别代表了组基本的输入字节流和输出字节流。InputStream类与OutputStream类均为抽象类,我们在实际使用中通常使用Java类库中提供的它们的一系列子类。下面我们以InputStream类为例,来介绍下Java中的字节流。
InputStream类中定义了一个基本的用于从字节流中读取字节的方法read,这个方法的定义如下:
public abstract int read() throws IOException;
这是一个抽象方法,也就是说任何派生自InputStream的输入字节流类都需要实现这一方法,这一方法的功能是从字节流中读取一个字节,若到了末尾则返回-1,否则返回读入的字节。关于这个方法我们需要注意的是,它会一直阻塞知道返回一个读取到的字节或是-1。另外,字节流在默认情况下是不支持缓存的,这意味着每调用一次read方法都会请求操作系统来读取一个字节,这往往会伴随着一次磁盘IO,因此效率会比较低。有的小伙伴可能认为InputStream类中read的以字节数组为参数的重载方法,能够一次读入多个字节而不用频繁的进行磁盘IO。那么究竟是不是这样呢?我们来看一下这个方法的源码:
public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
}
它调用了另一个版本的read重载方法,那我们就接着往下追:
public int read(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return 0;
} int c = read();
if (c == -1) {
return -1;
}
b[off] = (byte)c; int i = 1;
try {
for (; i < len ; i++) {
c = read();
if (c == -1) {
break;
}
b[off + i] = (byte)c;
}
} catch (IOException ee) {
}
return i;
}
从以上的代码我们可以看到,实际上read(byte[])方法内部也是通过循环调用read()方法来实现“一次”读入一个字节数组的,因此本质来说这个方法也未使用内存缓冲区。要使用内存缓冲区以提高读取的效率,我们应该使用BufferedInputStream。
3. 字符流(重要)
Java中的字符流处理的最基本的单元是Unicode码元(大小2字节),它通常用来处理文本数据。Writer和Reader这两个抽象类是是基本的字符流的祖先。所谓Unicode码元,也就是一个Unicode代码单元,范围是0x0000~0xFFFF。在以上范围内的每个数字都与一个字符相对应,Java中的String类型默认就把字符以Unicode规则编码而后存储在内存中。然而与存储在内存中不同,存储在磁盘上的数据通常有着各种各样的编码方式。使用不同的编码方式,相同的字符会有不同的二进制表示。实际上字符流是这样工作的:
- 输出字符流:把要写入文件的字符序列(实际上是Unicode码元序列)转为指定编码方式下的字节序列,然后再写入到文件中;
- 输入字符流:把要读取的字节序列按指定编码方式解码为相应字符序列(实际上是Unicode码元序列从)从而可以存在内存中。
我们通过一个demo来加深对这一过程的理解,示例代码如下:
import java.io.FileWriter;
import java.io.IOException; public class FileWriterDemo {
public static void main(String[] args) {
FileWriter fileWriter = null;
try {
try {
fileWriter = new FileWriter("demo.txt");
fileWriter.write("demo");
} finally {
fileWriter.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
以上代码中,我们使用FileWriter向demo.txt中写入了“demo”这四个字符,我们用十六进制编辑器WinHex查看下demo.txt的内容:
从上图可以看出,我们写入的“demo”被编码为了“64 65 6D 6F”,但是我们并没有在上面的代码中显式指定编码方式,实际上,在我们没有指定时使用的是操作系统的默认字符编码方式来对我们要写入的字符进行编码。
由于字符流在输出前实际上是要完成Unicode码元序列到相应编码方式的字节序列的转换,所以它会使用内存缓冲区来存放转换后得到的字节序列,等待都转换完毕再一同写入磁盘文件中。
下面附两个例子,一个写内容到文件,一个读取文件内容: 一个利用FileWriter写文件的例子:
@Test
public void test1() throws IOException{
File file = new File("./test.txt");
if(!file.exists()){//如果文件不存在就创建文件
file.createNewFile();
}
Writer writer = new FileWriter(file);//此构造方法也接收一个URI参数(文件名字)
writer.write("this is test");
writer.close();
}
结果:
一个利用FileReader读文件的例子:
@Test
public void test2() throws IOException{
Reader reader = new FileReader("./test.txt");//此构造方法也接收一个URI参数(文件名字)
int read = 0;
while ((read = reader.read())!=-1) {
System.out.print((char)read);
}
reader.close();
}
结果:
this is test
4. 字符流与字节流的区别
经过以上的描述,我们可以知道字节流与字符流之间主要的区别体现在以下几个方面:
- 字节流操作的基本单元为字节;字符流操作的基本单元为Unicode码元。
- 字节流默认不使用缓冲区;字符流使用缓冲区。
- 字节流通常用于处理二进制数据,实际上它可以处理任意类型的数据,但它不支持直接写入或读取Unicode码元;字符流通常处理文本数据,它支持写入及读取Unicode码元。
5.InputStreamReader:字节到字符的桥梁。OutputStreamWriter:字符到字节的桥梁。
1. InputStreamReader 是字节流通向字符流的桥梁
// 该方法中nputStreamReader使用系统默认编码读取文件. private static void testReadFile(File file) throws IOException { FileInputStream fis = new FileInputStream(file); InputStreamReader ins = new InputStreamReader(fis); int len = 0; while ((len = ins.read()) != -1) { System.out.print((char) len); } ins.close(); fis.close(); } // 该方法使用指定编码读取文件 private static void testReadFile(File file, String encod) throws IOException { FileInputStream fis = new FileInputStream(file); InputStreamReader ins = new InputStreamReader(fis, encod); int len = 0; while ((len = ins.read()) != -1) { System.out.print((char) len); } ins.close(); } }
另一种Runtime执行的时候inputStream转BufferReader
public static void main(String[] args) {
String cmd1 = "jps | findstr server";
Runtime runtime = Runtime.getRuntime();
Process process = null;
try {
process = runtime.exec(cmd1); InputStream inputStream = process.getInputStream();
Reader reader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(reader);
String line = null;
while ((line = bufferedReader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
2. OutputStreamWriter 是字符流通向字节流的桥梁
// 使用系统码表将信息写入到文件中 private static void testWriteFile(File file) throws IOException { FileOutputStream fos = new FileOutputStream(file); OutputStreamWriter ops = new OutputStreamWriter(fos); ops.write("中国"); ops.close(); } // 使用指定码表,将信息写入到文件中 private static void testWriteFile(File file, String encod) throws IOException { FileOutputStream fos = new FileOutputStream(file); OutputStreamWriter ops = new OutputStreamWriter(fos, encod); ops.write("中国"); ops.close();
参考:https://www.cnblogs.com/qlqwjy/p/7513187.html 补充:关于FileInputStream中的读取方法的解释
如果传入了缓冲数组,内容是存储到缓冲数组中,返回值是存储到缓冲数组中的字节个数。
如果使用read方法没有传入缓冲数组,那么返回值是读取到的内容。
比如,一个文件内容如下:
what?1
(1)不传缓冲数组:
FileInputStream fileInputStream = new FileInputStream(new File("G:/test.txt")); int readData = -1;
while ((readData = fileInputStream.read()) != -1) {
System.out.println((char) readData);
}
结果:
w
h
a
t
?
1
(2)传入缓冲数组:
public static void main(String[] args) throws IOException {
FileInputStream fileInputStream = new FileInputStream(new File("G:/test.txt")); byte[] allDatas = new byte[0];
byte[] buffer = new byte[1024];
int length = 0;
// while ((length = fileInputStream.read(buffer, 0, 1024)) != -1) {
// 等价于上面注释掉的
while ((length = fileInputStream.read(buffer)) != -1) {
allDatas = ArrayUtils.addAll(allDatas, ArrayUtils.subarray(buffer, 0, length));
}
System.out.println(new String(allDatas));
}
结果:
what?1
源码查看:
(1)read: 调用本地方法获取数据
/**
* Reads a byte of data from this input stream. This method blocks
* if no input is yet available.
*
* @return the next byte of data, or <code>-1</code> if the end of the
* file is reached.
* @exception IOException if an I/O error occurs.
*/
public int read() throws IOException {
Object traceContext = IoTrace.fileReadBegin(path);
int b = 0;
try {
b = read0();
} finally {
IoTrace.fileReadEnd(traceContext, b == -1 ? 0 : 1);
}
return b;
} private native int read0() throws IOException;
(2)read(byte[])和read(byte[], int off, int length):将内容读取到缓存数组中
public int read(byte b[]) throws IOException {
Object traceContext = IoTrace.fileReadBegin(path);
int bytesRead = 0;
try {
bytesRead = readBytes(b, 0, b.length);
} finally {
IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
}
return bytesRead;
} public int read(byte b[], int off, int len) throws IOException {
Object traceContext = IoTrace.fileReadBegin(path);
int bytesRead = 0;
try {
bytesRead = readBytes(b, off, len);
} finally {
IoTrace.fileReadEnd(traceContext, bytesRead == -1 ? 0 : bytesRead);
}
return bytesRead;
} /**
* Reads a subarray as a sequence of bytes.
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @exception IOException If an I/O error has occurred.
*/
private native int readBytes(byte b[], int off, int len) throws IOException;
两个方法内部原理一样,都是调用了一个本地方法,传入三个参数,第一个参数是需要缓存的字节数组,第二个是数组的起始地址,length是最大读取的字节数。
Java的IO流——(七)的更多相关文章
-
java的Io流学习
Java中io流的学习(一)File:https://blog.csdn.net/qq_41061437/article/details/81672859 Java中io流的学习(二)FileInpu ...
-
Java基础-IO流对象之File类
Java基础-IO流对象之File类 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.IO技术概述 回想之前写过的程序,数据都是在内存中,一旦程序运行结束,这些数据都没有了,等下 ...
-
java的IO流
java的IO流继承四大抽象类分别是字节流 inputStream outputStream与字符流 read write.怎么理解记忆很重要. 直接连接读写对象的是结点流,例如对文件读取字节类的名字 ...
-
Java基础——IO流
今天刚刚看完java的io流操作,把主要的脉络看了一遍,不能保证以后使用时都能得心应手,但是最起码用到时知道有这么一个功能可以实现,下面对学习进行一下简单的总结: IO流主要用于硬板.内存.键盘等处理 ...
-
【Java】IO流简单分辨
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/5827509.html Java的IO流体系十分庞大,并且体系层次稍复杂,很容易记混或记错.在此,我把平时经常用 ...
-
Java - 文件(IO流)
Java - 文件 (IO) 流的分类: > 文件流:FileInputStream | FileOutputStream | FileReader | FileWriter ...
-
Java中IO流的总结
有关Java中IO流总结图 流分类 按方向分 输入流 输出流 按单位分 字节流 字符流 按功能分 节点流 处理流(过滤流) 其他 所有的流继承与这四类流:InputSteam.OutputStream ...
-
JAVA中IO流总结
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/42119261 我想你对JAVA的IO流有所了解,平时使用的 ...
-
第15章-输入/输出 --- 理解Java的IO流
(一)理解Java的IO流 JAVA的IO流是实现输入/输出的基础,它可以方便地实现数据的输入/输出操作,在Java中把不同的输入/输出(键盘.文件.网络连接等)抽象表述为"流"( ...
-
Java基础IO流(二)字节流小案例
JAVA基础IO流(一)https://www.cnblogs.com/deepSleeping/p/9693601.html ①读取指定文件内容,按照16进制输出到控制台 其中,Integer.to ...
随机推荐
-
在WPF按钮删除默认的鼠标悬停效果
如果你想在应用程序的所有按钮将此风格,那么这种风格可以插入Application.Resources部分的App.xaml页面. <Window.Resources> <Style ...
-
android Studio 百度KEY获得发布版 SHA1 的方法
看图说话 build-->Generate Signed APK... create new(看不懂单词意思的同胞可以参考这个网址http://www.cnblogs.com/why168888 ...
-
转:C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
String.IndexOf String.IndexOf 方法 (Char, Int32, Int32)报告指定字符在此实例中的第一个匹配项的索引.搜索从指定字符位置开始,并检查指定数量的字符位置. ...
-
【wikioi】1116 四色问题
题目链接 算法:DFS 刚开始卡了一下,但后面想了想,于是 放上代码: #include <iostream> using namespace std; bool map[9][9]; i ...
-
stdlib
system(pause): int cmp(const void *a ,const void *b) { return *(int *)a - *(int *)b ; //从小到 ...
-
Jenkins+git+gitlab实现持续自动集成部署
1 实验环境 三台服务器 gitlab 192.168.7.139 Jenkins 192.168.7.140 java 192.168.7.141 [root ...
-
测试TCP 和 UDP 端口的方法
测试 TCP 端口: telnel IP PORT nc -vz IP PORT 测试 UDP 端口: nc -vuz IP PORT 其中 -u 表示使用 udp 协议来进行测试. -u, --ud ...
-
Zabbix3.4.7监控windows进程
1.首先,找到要监控进程的主机 创建新的监控项 然后应用集选择processes,点击添加,此处是以zabbix_agentd.exe为例添加 2. 为此监控项添加触发器 注意触发器表达式的编写,上面 ...
-
background 的一些 小的细节: 1, 背景色覆盖范围: border+ width+ padding ;背景图覆盖范围: width + padding ; 2设置多个背景图片 ; 3) background-position定位百分比的计算方式: 4)background-clip 和 background-origin 的区别
1. background (background-color, background-image) 背景色覆盖范围: border+ width+ padding ;背景图覆盖范围: width ...
-
HDU 2093 考试排名 模拟题
解题报告: 题目描述:写一个程序给一个编程考试C++实时提交系统排名,给你的数据是题目的总数,每次错误提交罚的时间分,每位用户的姓名,然后是输入用户每题的完成情况,有一下几种情况,第一,输入只有一个正 ...