Io Stream Practice 5--reading a string in a file, sorting after it is written to another file

Source: Internet
Author: User

Requirement: There is a string in the known S.txt file: "HCEXFGIJKAMDNOQRZSTUVWYBPL"
Please write the program to read the data content, sorting the data after writing to Ss.txt.
Analysis:
A: Reading data from a file
B: The data exists in a string
C: Convert a string to a string array
D: Sorting a string array
E: Array converted to string
F: Write the string to the file

1  Public Static voidMain (string[] args)throwsIOException {2         //read the data buffer character input stream in a file3BufferedReader br =NewBufferedReader (NewFileReader ("S.txt"));4         //put the data in a string5String s =br.readline ();6 br.close ();7         //Convert a string to a string array8         Char[] ch =S.tochararray ();9         //to sort a string arrayTen arrays.sort (CH); One         //array into string AString result =NewString (CH); -          -         //writes a string to the file buffer character output stream theBufferedWriter BW =NewBufferedWriter (NewFileWriter ("Ss.txt")); - bw.write (result); - bw.close (); -  +}

Io Stream Practice 5--reading a string in a file, sorting after it is written to another file

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.