CodeGym /Courses /Java Core /Practice with FileReader/FileWriter

Practice with FileReader/FileWriter

Java Core
Level 9 , Lesson 5
Available

"Hello, Amigo!"

12
Task
Java Core, level 9, lesson 5
Locked
Even characters
Read 2 file names from the console. Output to the second file all characters from the first file with an even ordinal number (ordinal numbers start with 1). Example first file: text in file Output in the second file: eti ie Close the IO streams.
20
Task
Java Core, level 9, lesson 5
Locked
Counting words
Read a file name from the console. The file contains words separated by punctuation marks. Output to the console the number of times the word "world" appears in the file. Close the streams.
20
Task
Java Core, level 9, lesson 5
Locked
Picking out numbers
Read 2 file names from the console. Output to the second file all of the numbers from the first file. Separate the numbers with a space. Close the streams. Example file content: 12 text var2 14 8v 1 Result: 12 14 1
12
Task
Java Core, level 9, lesson 5
Locked
Changing punctuation marks
Read 2 file names from the console. The first file contains text. Read the contents of the first file and change all the periods (".") to exclamation points ("!"). Then output the result to the second file. Close the streams.
12
Task
Java Core, level 9, lesson 5
Locked
Punctuation
Read 2 file names from the console. The first file contains text. Read the contents of the first file, and remove all punctuation marks, including newline characters. Then output the result to the second file. Close the streams.
Comments (15)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
catalin1989 Level 37, Romania
18 November 2023
This task made me feel more comfortable with the reges expresions.
LuisRC Level 39, Gijón, Spain
6 April 2022
The use of REGEX pattern is an easy issue to me. I have read about it on INTERNET but I got it stiil more blurred.
Justin Smith Level 41, Greenfield, USA, United States
19 October 2021
This chapter is secretly actually about working with regex. The filereader/filewriter part is basically pretty simple and doesn't really change much from task to task. Tip. Putting a character inside square brackets avoids the need to look up most escape sequences. i.e. "[!#.]" will match "!", "#", and "."
Thành Black Level 49, Hanoi
3 October 2021
"\\p{P}","". I need Explain.
Jurij Thmsn Level 29, Flensburg, Germany
18 April 2021
these tasks were more about RegEx than I/O. check out this page (choose java on the left and look on the bottom right for RegEx quick references): https://regex101.com/
Jackson Cummins Level 24, United States
25 January 2021
On the counting words task use "\\W" to split the string instead of "\\p{Punct}" even though the task says "The file contains words separated by punctuation marks." I kept failing the verification because of this and couldn't figure out why until I looked at the help section.
Gellert Varga Level 23, Szekesfehervar, Hungary
21 September 2021
I replaced all whitespaces with '.' and then \\p{Punct} was also accepted. -- And a little bit more precise description of the task would like this: - "The file contains words separated by punctuation marks and/or whitespaces", - the words "world" count only in lower case, - "worlds", "worldly" : these do not count.
Simphiwe Level 33, Johannesburg, South Africa
2 April 2023
Good shot. But why didn't \\p{P} work?
Chandan Thapa Level 22, Dubai, United Arab Emirates
9 January 2021
Great tasks! :)
Sanjay Chauhan Level 28, Delhi, India
23 March 2020
one tip I would like to share with you, always check others solution in the help section after you pass the task, you will see some amazing solution and learn to write the better code. Happy learning.
MaGaby2280 Level 41, Guatemala City, Guatemala
10 March 2020
Hard ones, but nice ones... mind all spaces carefully!
Joseph Level 22, United States
12 November 2019
Both StringBuilder and regular expression came in handy