Write a java program for file processing

Assignment Help JAVA Programming
Reference no: EM133452280

Operating Systems

Question: Write a Java or C/C++ (the choice is yours) program for file/directory processing according to the following rules. The program requested for this homework must have a text menu like this:

0  - Exit

1  - Select directory

2  - List directory content

3  - Display file (hexadecimal view)

4  - Delete file

5  - Mirror reflect file (byte level) Select option:

The menu is displayed and the user must select an option (a number between 0 and 5). The action corresponding to the selection is performed, then the menu is displayed again and the user can choose another option. This cycle is repeated until the user selects 0, which exits the loop and ends the program execution.

The options are:

0 - Exit

This options ends the program execution. This option should always work.

1 - Select directory

The user is prompted for an [absolute] directory name (path). This is the first options that must be selected by the user. All the options below are working on the directory selected here. The directory name (path) must be correctly formatted and the directory must exist (the program must check for this and issue error messages if necessary).

After performing several operations on the selected directory, the user can select another directory and work with it. If a user (by mistake or otherwise) selects any other option from the menu before selecting this one, an error message must be displayed instructing the user to select a directory first.

2 - List directory content

This option displays the content of the directory (previously selected by option 1) on the screen. All the files and sub-directories from the first level ONLY must be displayed (files and directories should be listed separately one item per line, directories first). For each file, its size must also be displayed, in bytes. If no directory was selected an error message must be displayed.

3 - Display file (hexadecimal view)

This option prompts the user for a filename (from the directory selected by option 1) and displays the content of that file on the screen, in hexadecimal view. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file.

Note: The hexadecimal view displays each byte of the file in hexadecimal, 16 bytes per line, separated by one white space; each byte must occupy two characters on the screen. It should look something like this (please note that the letters A to F must be in upper case !!!):

52 61 72 21 1A 07 01 00 96 45 15 22 0C 01 05 08

00

07

01

01

D3

94

89

80

00

CA

47

9D

13

4A

02

03

0B

F3

93

09

04

95

A1

09

20

F7

2B

31

75

80

0B

00

2C

57

68

61

74

73

41

70

70

20

49

6D

61

67

65

20

32

30

32

32

2D

30

35

2D

31

31

20

61

74

20

37

2E

33

34

2E

31

34

20

50

4D

2E

6A

70

65

67

0A

03

02

F4

FF

17

13

CB

65

D8

01

8E

87

16

45

67

06

55

53

22

65

66

70

37

76

D4

D1

22

42

00

90

8C

20

D0

51

01

22

C0

EA

28

D0

34

02

03

01

04

08

28

49

10

58

29

4A

28

8D

02

88

88

95

AC

04

12

95

29

60

0A

55

01

12

85

7A

08

0D

42

89

4A

28

A5

30

10

51

51

51

51

29

45

45

20

22

08

BD

71

BD

F5

BF

31

1D

F7

DF

9C

79

DE

FB

E3

EF

F5

F7

D1

B2

13

53

3A

CD

5C

F3

AC

E7

38

CE

28

87

A6

71

F8

27

CC

63

39

E3

34

73

8F

4A

FF

5E

6F

EB

D8

21

13

5B

16

CD

88

83

06

08

20

7F

25

E9

FD

5E

09

12

26

69

2F

A4

D0

F6

3C

7A

69

04

FF

F3

4A

59

B5

05

0C

DA

91

42

2A

7F

E0

A2

DA

A6

79

53

FF

94

B6

B0

B8

B0

AC

97

 

 

 

 

4 - Delete file

This option prompts the user for a filename and deletes that file from the selected directory. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file.

5 - Mirror reflect file (byte level)

This option prompts the user for a filename (from the selected directory) and performs an operation we will call "mirror reflection" for every byte of that file. If no directory was selected an error message must be displayed. If the directory does not contain the file specified by the user, another error message must be displayed. The filename does not include any path, it's just the name of the file.

Note: Mirror reflection for a certain byte (which, as we know, is a string of 8 bits) changes the order of its bits just like a real world mirror does for any image: what was on the left side will appear on the right side and vice versa.

More concretely, let's denote the bits of a byte as b1b2b3b4b5b6b7b8. After the mirror reflection operation, they will be rearranged as b8b7b6b5b4b3b2b1.

Hints: The required actions are: read the whole file into a memory buffer (we assume the file is small enough), then perform the mirror reflection for every byte of the memory buffer, then we write back the buffer into the file (we overwrite the file) resulting a file with the same size in bytes.

No additional file must or should be used, as the initial file must be overwritten. Clearly if we apply this operation twice, we must obtain again the initial file content.

Testing procedure:

0. Option 0 requires just one screenshot, for successful exit.

1. Option 1 requires one screenshot for a correct directory name (path) and one screenshot for an incorrect directory name (path).

2. Option 2 requires one screenshot showing the error (no directory was selected yet) and another one showing the content of the selected directory; make sure the directory you use contains at least three files and three subdirectories.

3. Option 3 requires screenshots showing the errors (no directory was selected yet, file does not exist) and another one showing the content of the selected file; make sure the display follows the required formatting.

4. Option 4 requires screenshots showing the errors (no directory was selected yet, file does not exist) and another one/two showing the content of the selected directory before and after deleting the file.

5. Option 5 requires screenshots showing the errors (no directory was selected yet, file does not exist) and others showing the hex view of the file before and after mirroring (also, make sure the file size remains the same).

Reference no: EM133452280

Questions Cloud

Identify and explain the marketing communication tool : Identify and explain the marketing communication tool (advertising - type of advertisement, public relations and publicity, personal selling and sales promotion
Is there a difference between project time management : Is there a difference between project time management and personal time management? Can someone be " good " at one but not the other? Explain your answer
What can we learn from this case about large capital : Explain your reasons for making this choice. What can we learn from this case about large capital investments in developing countries by US firms?
Identify a real-life adverse event that has occurred : identify a real-life adverse event that has occurred in a healthcare environment in the last five years. Provide an overview of the adverse event you selected
Write a java program for file processing : CMSC 412 Operating Systems, University of Maryland Campus, Write a Java program for file processing - The menu is displayed and the user must select an option
How the conclusions from 2 could be applied : An introduction of the chosen organisation and set out the existing and emerging challenges posed by digital disruption within that sector or profession
What conditions seem to increase or decrease your target : What conditions seem to increase or decrease your target behavior - outside having more patience with someone who is frustrating reading more books drawing
Write about how you can use your knowledge of erikson : Write about how you can use your knowledge of Erikson's stages of psychosocial development either personally or professionally in the future
How are you ensuring ethical conduct in your research : Let them know how you think subjects will respond to the experiment (basically, what is your hypothesis of their experiment?)

Reviews

len3452280

6/22/2023 10:08:36 PM

Correct input is provided for each menu option (whether it’s a file or a directory name, etc.). Incorrect input is provided for each menu option. Score of Input (10%),/ 10 Output (10%) Program output is correct and complete. In particular, the hexadecimal view of files is correct. Program output is incorrect and/or incomplete. In particular, the hexadecimal view of files is incorrect. Score of Output (10%),/ 10 Error checking (10%) Error checking is performed for each menu option. Error checking is not performed for each menu option. Score of Error checking (10%),/ 10 Criteria Meets 20 points Does Not Meet 0 points Criterion Score Submission (20%) The source code for the Java/C/C++ program is included in the submission. The specified screenshots of program’s execution for each menu option are included in the submission. The source code for the Java/C/C++ program is not included in the submission. The specified screenshots of program’s execution for each menu option are not included in the submission.

len3452280

6/22/2023 10:08:02 PM

Hexadecimal view of a file is correct. File deletion works correctly. Byte level processing is correct. Program does not compile. Program does not provide the required menu. Directory selection and content listing work incorrectly. Hexadecimal view of a file is incorrect. File deletion works incorrectly. Byte level processing is incorrect. Score of Functionality (50%),/ 50 Criteria Meets 10 points Does Not Meet 0 points Criterion Score Input (10%)

len3452280

6/22/2023 10:07:50 PM

A Test Report showing the program performing each of the menu actions correctly (use the testing procedure described above, include all the required screenshots). Use this file (Homework 6.pdf) as the input file for options 3 and 5. Criteria Meets 50 points Does Not Meet 0 points Criterion Score Functionality (50%) Program compiles with a Java or C/C++ compiler. Program provides the required menu. Directory selection and content listing work correctly.

Write a Review

JAVA Programming Questions & Answers

  How to track password-cracking software

Imagine you are a digital forensic investigator for a healthcare organization. You learn from your internal information security department that an employee has been using password-cracking software to access confidential customer insurance inform..

  Write a static method named problem

Write a static method named problem3 that accepts a string. Replace every occurrence of the first character with "tiny_mce_markerquot; except for the first

  Supply constructor that makes polynomial from a single term

Supply methods to add, multiply, and print polynomials - Need help with the assignment

  Write a script that inputs three integers

Write a script that inputs three integers from the user and displays the sum, average, product, smallest and largest of the numbers in an alert dialog2

  Update an existing java program using the netbeans ide

you will update an existing Java program using the NetBeans IDE. You will use the NetBeans Integrated Development Environment to make changes to an existing NetBeans Java Project. This existing program correctly sorts the data without using thread..

  Write a program that creates an apartment object and prompts

Create a structure named Apartment that contains data fields to hold the number of bedrooms, the number of bathrooms, and the monthly rent for the apartment.

  You should complete the scaletozero and addnote methods

You should complete the scaleToZero, addNote, tune and altChannels methods. You can test your method with different parameter values by editing the RunEffects.java file

  Digit decimal seconds counter using two 7-segment displays

Write a program that implements a two digit decimal seconds counter using two 7-segment displays.  Make this program using java programming. Make this program in simple way.

  Please code in java to purchase bus tickets

Please code in Java to purchase bus tickets. Name, destination, from, citizen, discount if citizens, tax, price, total price, seat number, identity card, number

  Prepare a java code to show a multiplication table

A multiplication table is printed out for a range of positive numbers. The user is prompted to start with a number for example 2.

  Create a stock class to manage the stock activity

Create a GUI that uses JList andJTabbedPanes - Process multiple objects in an ArrayList and Code event handlers for multiple events

  Specify, design and implement a class

Specify, design and implement a class that can be used to hold information about a musical note. Test it with an appropriate driver program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd