Java self-taught-----FileInputStream class

Source: Internet
Author: User

1, the FileInputStream class function is created:

 PackageCorejava;ImportJava.io.FileInputStream;Importjava.io.IOException; Public classIoutil { Public Static voidPrinthex (String Filename)throwsioexception{/*** Read the specified file inside the glory, follow the 16 output to the console, and * No output 10byte line feed*/FileInputStream in=NewFileInputStream (Filename); intb; inti = 1;  while((b = in.read ())!=-1){            if(b <= 0xf){                //number of units front complement 0System.out.print ("0"); }            //output is displayed in 16-binary form and separated by a spaceSystem.out.print (integer.tohexstring (b) + ""); //line breaks when each row output is greater than or equal to 10 bytes            if(i++%10 = = 0) {System.out.println (); }        }        //close files to avoid exception errorsIn.close (); }}

2. Main function:

 Package Corejava; Import java.io.IOException;  Public class IOUtilTest1 {    publicstaticvoid main (string[] args)throws IOException {        //  TODO auto-generated method stub        ioutil.printhex ("e:\\ JAVA io\\testjava\\ unicom 1.txt ");}    }

Java self-taught-----FileInputStream class

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.