CodeGym /Courses /Java Core /Practice with FileInputStream and FileOutputStream

Practice with FileInputStream and FileOutputStream

Java Core
Level 8 , Lesson 3
Available

"Hello, Amigo!"

10
Task
Java Core, level 8, lesson 3
Locked
Maximum byte
Enter a file name from the console. Find the maximum byte in the file. Display it on the screen. Close the IO stream.
5
Task
Java Core, level 8, lesson 3
Locked
Minimum byte
Enter a file name from the console. Find the minimum byte in the file. Display it on the screen. Close the IO stream.
20
Task
Java Core, level 8, lesson 3
Locked
Most frequent bytes
Enter a file name from the console. Find the byte or bytes with the maximum number of repetitions. Display them on the screen, separated by spaces. Close the IO stream.
10
Task
Java Core, level 8, lesson 3
Locked
Rarest bytes
Enter a file name from the console. Find the byte or bytes with the minimum number of repetitions. Display them on the screen, separated by spaces. Close the IO stream.
10
Task
Java Core, level 8, lesson 3
Locked
Sorting bytes
Enter a file name from the console. Read all the bytes from the file. Ignoring repetitions, sort them by byte-code in ascending order. Display the result on the screen. Close the IO stream. Example of bytes in the input file: 44 83 44 Example output: 44 83
Comments (20)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Kent Hervey Level 19, United States Expert
9 November 2023
/* Comment has been deleted */
Brandon Waites Level 26, Cincinnati, United States
18 February 2023
Using HashMap has saved me so much headache for the final 3 bytes tasks
Boat Level 40, Germany, Germany
28 April 2023
TreeSet is also nice. Only takes unique elements and sorts them. Does the entire task on its own.
catalin1989 Level 37, Romania
6 November 2023
I have used HashSet. I think it is easier. I also thought of using HashMap.
Hoa Nguyen Level 15, Australia Expert
16 February 2022
what is 255 in solution code " int minByte = 255" to find the min byte and 256 in solution code int[] byteCountArray = new int[256] to find the most frequent byte?
whoseunassailable Level 28, India, India
16 April 2022
I think the size of a byte is 8 bits which ranges from 0 to 255.....and that makes it the size of 256
Thành Black Level 49, Hanoi
29 September 2021
Integer.MAX_VALUE = int minByte ????
Boat Level 40, Germany, Germany
28 April 2023
Guarantees that, no matter what, you will have a smaller integer available. Otherwise you could run into a situation where your minByte variable isn't smaller than anything and you get a bad result.
Chandan Thapa Level 22, Dubai, United Arab Emirates
26 December 2020
When they title the task level as "hard", they really mean it!! :))
Roman Grygorczuk Level 19, Cracow, Poland
2 March 2021
They do but not always it a case. I still cannot handle some easy one from syntax part ))
Chandan Thapa Level 22, Dubai, United Arab Emirates
4 March 2021
dont worry! i feel it will come with experience.. we will reach a point where it will be a muscle memory!
2 September 2019
FYI: the output for the last 3 tasks require an empty space at the end in order to verify
Justin Smith Level 41, Greenfield, USA, United States
28 September 2021
The good thing is that it's much harder to get this wrong than to get it right.
Ewerton Level 30, Belo Horizonte, Brasil
3 July 2019
Made me remember TreeSet.

Set<Integer> set = new TreeSet<>();  
set.add(24);  
set.add(66); 
set.add(66);  
set.add(15);
System.out.println(set);
[12,24,66]
Ahmed Level 23, Amsterdam, Netherlands
16 August 2019
I just saw your commit after doing the filter myself with arraylist :( Thanks anyway :)
2 September 2019
Whoa! didn't know about the TreeSet. Comes really handy. Thanks!
Juanf Level 1
10 October 2019
brilliant!
Oana Mancu Level 41, Bucharest, Romania
23 September 2020
+ HashMap for frequency
Oliver Heintz Level 18, Mustang, United States
5 March 2021
Glad I read the comments before I attempt the tasks. That made that last one a cinch.
JeRiF94 Level 22, Baku, Azerbaijan
15 June 2019
DONE