Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this java program, Create an application that reads, stores, and outputs data on a json file. Use at least six classes including the test

For this java program, Create an application that reads, stores, and outputs data on a json file. Use at least six classes including the test class. Note: The only library you can use is scanner, string, and/or date libraries. You cannot use any json, filereader, bufferreader, etc.

Ex: { "author": "fizaali12", "author_flair_css_class": null, "author_flair_text": null, "body": "5 foods you should never eat on an empty stomach", "created_utc": 1484601504, "id": "dcih4d0", "link_id": "t3_5odjx4", "parent_id": "t3_5odjx4", "score": 1, "stickied": false, "subreddit": "Health", "subreddit_id": "t5_2qh9z" }

Output: "author": "fizaali12", "author_flair_css_class": null, "author_flair_text": null, "body": "5 foods you should never eat on an empty stomach", "created_utc": 1/16/2017, 4:18:24 PM, "id": "dcih4d0", "link_id": "t3_5odjx4", "parent_id": "t3_5odjx4", "score": 1, 4 "stickied": false, "subreddit": "Health", "subreddit_id": "t5_2qh9z", "count": {"the_number_of_non_null_fields": 10, "the longest_field": "body", " the longest_field_value_length": 48, "the_highest_score": 1, "the_highest_score_date": 1/16/2017, 4:18:24 PM, "the_most_frequent_words_in_all_comments": [{"stomach":2}]} }

This is what I have so far about reading the file. Just a general class in which the file is read:

public class ScannerExample {

public static void main(String args[]) throws FileNotFoundException { System.out.print("Enter the file name with its location and extension : "); Scanner input = new Scanner(System.in); File text = new File(input.nextLine()); //Creating Scanner instnace to read File in Java Scanner scnr = new Scanner(text); //Reading each line of file using Scanner class int lineNumber = 1; while(scnr.hasNextLine()){ String line = scnr.nextLine(); System.out.println("line " + lineNumber + " :" + line); lineNumber++;

}

I was wondering how I should approach storing, and outputting the information without being able to use the traditional output libraries.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

demonstrate the importance of induction training.

Answered: 1 week ago