Job 4.2

Source: Internet
Author: User

This experiment and Fan classmate knot to complete.

This program in the last program slightly modified, to increase the function of search words, the main code is as follows:

  Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.println ("Please enter the word you want to find"); String m=In.nextline (); intCount=0; Try{FileReader FR1=NewFileReader ("Gone_with_the_wind.txt");//ReadBufferedReader bf1=NewBufferedReader (FR1); String Str=NULL;  while((Str=bf1.readline ())! =NULL) {str=str.replace ("\\n", "" "); STR=str.tolowercase (); STR=str.replaceall ("[\\pP '" ""] "," "); String[] str1=str.split ("");  for(inti=0;i<str1.length;i++)          {              if(M.equals (Str1[i])) count++; }} fr1.close ();         Bf1.close (); }Catch(Exception e) {e.printstacktrace ();} Try{FileWriter FW=NewFileWriter ("Result1.txt"); BufferedWriter BW=NewBufferedWriter (FW); Bw.write (M+"="+count);             Bw.close (); Fw.close (); }Catch(Exception e) {e.printstacktrace ();} }      }

Experimental data:

I searched for 3 words, which with has, and compared to the last result

Consistent results

GitHub Address: Https://github.com/sunhongyi1996/repository

Job 4.2

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.