This system is scrutinizing the substance of the united text archive and a short time later searching
Question:
This system is scrutinizing the substance of the united text archive and a short time later searching for the expressions */ private static void searchKeywords() throws IOException { // presenting the br variable BufferedReader br = invalid; // using the endeavor/get methodology to manage the exceptional cases endeavor { // making one more factor with the value of an unfilled string String content; // arrangement of the BufferReader object br = new BufferedReader(new FileReader(mergeFilePath)); // using the while circle to investigate the substance from the record, as a matter of fact while ((content = br.readLine()) != invalid) { // passing each line of the glanced through blissful keywordsSearch(content); } } get (FileNotFoundException e) { e.printStackTrace(); } finally {//the finally block by and large executes if(br != invalid) { endeavor { br.close(); } get (IOException e) { e.printStackTrace(); } } } }
1. A lone Java program on Constructor execution hierarchy
2. A singular Java program for String pad class that covers constructors, length(), limit(), ensure Capacity(), set Length(), charAt(), setCharAt(), getChars(), add(), install(), rearrange(), eradicate(), deleteCharAt(), override().
3. A ceaseless Java program on Abstract class
4. A continuous Java program using last
/**
With the going with code below...I need help with the going with requests. Written in the programming language java with comments getting a handle on the code methods and significance.
import org.json.JSONException; import org.json.JSONObject;
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern;
/**
* * The inspiration driving this undertaking is to mix various single reports into a singular record. Then, at that point, inside * the consolidated archive, search for the gave expressions and print out its close_date and * funds_raised_percent. */ public class MyFileMerger {
// constants static last String mergeFilePath = "mergedFile.json"; static last String filePath1 = "file1.json"; static last String filePath2 = "file2.json"; static last String filePath3 = "file3.json";
public static void main(String[] args) throws IOException {
// scrutinizing from the three given records and staying in contact with them into the merged report newFileReaderAndWriter(filePath1); newFileReaderAndWriter(filePath2); newFileReaderAndWriter(filePath3); // searching for the gave watchwords in the joined record searchKeywords(); }
/** * This method is scrutinizing the substance from various and making the substance to the record that necessities * to be mixed * @param fileNamePath tends to the main technique to examine the archive from */ classified static void newFileReaderAndWriter(String fileNamePath) throws IOException { // presenting the br variable // presenting the bw variable
endeavor (BufferedWriter bw = new BufferedWriter(new FileWriter(mergeFilePath, substantial)); BufferedReader br = new BufferedReader(new FileReader(fileNamePath))) { // making of the BufferWriter object // set addition to substantial with the new filewriter record // making of the BufferReader object // the fileNamePath with the filereader object
// making one more factor with the value of an unfilled string String line; // using the while circle to investigate the substance from the record, as a matter of fact while ((line = br.readLine()) != invalid) { bw.write(line + " "); } // get handle unique case } get (FileNotFoundException e) { e.printStackTrace();//print the unique case nuances } // the finally block for the most part executes }
/** * This method is being used to search for the watchwords in each line using the regex procedure * @param line tends to the given watchwords that ought to be through searched in each line */ classified static void keywordsSearch (String line) { // list object List expressions = new ArrayList<>();
// add the expressions to the summary // then, at that point, gather the watchwords to make configuration using organize() procedure keywords.add(Pattern.compile("robots")); keywords.add(Pattern.compile("fitness")); keywords.add(Pattern.compile("wearable"));
// using the for circle to check whether the watchwords match for(Pattern p: watchwords) { // get a matcher object Matcher m = p.matcher(line); // using the .find system to search for the specific model if (m.find()) { stringToJsonObj(line); } }
}
/** * This method will switch string over totally to json * * @param line tends to the watchwords that match past method **/
secret static void stringToJsonObj(String line) { endeavor { // making of a new json object JSONObject js = new JSONObject(line); JSONObject data = js.getJSONObject("data"); twofold funds_raised_percent = data.getDouble("funds_raised_percent"); // print out funds_raised_percent System.out.println("funds_raised_percent: " + funds_raised_percent); // used optString rather than getSting in light of the fact that I wasn't sure about whether the data was missing String close_date = data.optString("close_date"); // print out close_date System.out.println("close_date: " + close_date); } get (JSONException e){ e.printStackTrace(); } } }
I moreover gave an image of the JSON report. So if both of the expressions from the code is accessible in the display, then, at that point, it should print the class, close_date, funds_raised_percent, and the tag_line