Examples of FileOutputStream and FileInputStream use in Java

Source: Internet
Author: User

 PackageA.ab;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException; Public classAC {ints = 0;  Public Static voidMain (string[] args) {FileOutputStream fos=NULL; Try{fos=NewFileOutputStream ("D:\\dd\\ff.txt"); } Catch(filenotfoundexception E2) {//TODO auto-generated Catch blockE2.printstacktrace (); }        Try{fos.write ("Ddsfs, the high speed of the east, and the low V is VSDF". GetBytes ()); } Catch(IOException E1) {e1.printstacktrace (); }        Try {            if(Fos! =NULL) {fos.close (); }        } Catch(IOException e) {e.printstacktrace (); }        Try{FileInputStream fis=NewFileInputStream ("D:\\dd\\ff.txt"); byte[] by =New byte[1024]; intb = 0; Try {                 while((b = fis.read (by))! =-1) {System.out.println (NewString (by, 0, b)); }            } Catch(IOException e) {e.printstacktrace (); } finally {                if(FIS! =NULL) {                    Try{fis.close (); } Catch(IOException e) {e.printstacktrace (); }                }            }        } Catch(FileNotFoundException e) {e.printstacktrace (); }    }}
View Code

Examples of FileOutputStream and FileInputStream use in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.