The character stream of I/O in Java

Source: Internet
Author: User

Character Stream is based on characters when reading and writing files

Core classes of character streams in I/O

The reader and writer classes are the parent classes of all character stream classes, as well as abstract classes. FileReader and FileWriter are their subclasses, respectively.

Core methods of the core class:

Reader:

int read (char [] c, int off, int len);

Writer:

void write (char [] c, int off, int len);
Import java.io.*;p ublic class test{public static void Main (String args[]) {FileReader FR = null; FileWriter FW = NULL;TRY{FR = new FileReader ("F:/android/java4android/33/src/a.txt"), FW = new FileWriter ("F:/android/ Java4android/33/src/b.txt "); char [] c = new Char [100];int cLen = Fr.read (c,0,c.length); Fw.write (C,0,clen);} catch (Exception e) {System.out.println (e);} Finally{try{fr.close (); Fw.close ();} catch (Exception e) {System.out.println (e);}}}}

for (int i = 0;i <c.length;i++) {System.out.println (c[i]);}

The character stream of I/O 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.