5
Sarcină
Java Core, nivel, lecţie
Fix the bugs
Fix the functionality according to the requirements.
The program should:
1. Write all the bytes from one file into another in one batch.
2. Close the IO streams.
Hint: There are 4 bugs.
10
Sarcină
Java Core, nivel, lecţie
Counting commas
Read a file name from the console.
Count the number of commas (',') in the file. Display the number.
Close the streams.
Hint: You need to compare with the ASCII code for ','.
20
Sarcină
Java Core, nivel, lecţie
Splitting a file
Read 3 file names from the console: file1, file2, file3.
Split file1 as follows:
Write the first half of its bytes to file2,and write the second half of its bytes to file3.
If the number of bytes in file1 is odd, then file2 should contain the larger half.
Close the streams.
10
Sarcină
Java Core, nivel, lecţie
Reversing a file
Read 2 file names from the console: file1, file2.
Write all the bytes in file1 to file2, but in the reverse order.
Close the streams.
10
Sarcină
Java Core, nivel, lecţie
DownloadException
1 Read file names from the console.
2 If the file is less than 1000 bytes, then:
2.1 Close the file stream.
2.2. Throw a DownloadException.