the basic process for local file read and write programming is:
① generates a file stream object (should be the FileInputStream class for file read operations, and the file should be FileOutputStream Class);
② calls a function function in the FileInputStream or FileOutputStream class, such as read (), write (int b), to read and write the contents of the file;
③ Closes the file (Close ()).
Read the file under a certain path, filename = new file ("D:\\123.txt"), try {fileinputstream fis=new fileinputstream (file);// Create a new FileInputStream object try {byte[] b=new byte[fis.available ()];//Create a new byte array fis.read (b);//reads the contents of the file into a byte array fi S.close (); String Str2=new string (b);//The contents of the byte array are then converted into a string output System.out.println (STR2); } catch (IOException e) {e.printstacktrace (); }} catch (FileNotFoundException e) {e.printstacktrace ();} File writes FileOutputStream file_out = new FileOutputStream (file); File_out.write (outputdata); Byte data file_out.close ();
Classes inherited from InputStream and outputstream for local file reads and writes (binary format read and write, sequential read and write, separate file stream objects to be created by reading and writing)
Http://www.cnblogs.com/kyxyes/archive/2013/02/16/2913424.html
Http://www.cnblogs.com/jjtech/archive/2011/04/17/2019210.html
Java--Simple use of fileinputstream and FileOutputStream