Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Language: Java I am attempting to find a way to delete over 2,400 lines of a cer

ID: 3692592 • Letter: L

Question

Language: Java

I am attempting to find a way to delete over 2,400 lines of a certain code... I am trying to delete every line except for the bolded lines... Remember each time this code occurs the values may be different. I WOULD LIKE THE FULL CLASS FILE READY TO RUN, I am going to be putting it into a folder and running through a batch file.

The file is called "itemdef.txt" it will be located in the same folder.

This is what the code looks like:

{
"id": 9,

"name": "Different Names",
"desc": "Different Descriptions.",
"value": different values,
"dropValue": 0,
"bonus": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"slot": -1,
"fullmask": false,
"stackable": true,
"noteable": true,
"tradable": true,
"wearable": false,
"showBeard": true,
"members": true,
"twoHanded": false,
"requirements": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]

},

Thank you very much :)

Explanation / Answer

Observe your file itemdef for location and boldness before the execution of the program

Bold text in java really depends on what kind of console is being used. For IDEs like Netbeans and Eclipse, I'm not sure if you can affect the font. But for most terminals, the following escape character works:

OR

System.out.println((char)27+"u001B[1m testing bold text");

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bold;

import java.io.BufferedReader; // buffered reader to read the file
import java.io.BufferedWriter; // buffered writer to write the file
import java.io.FileNotFoundException; //file not found exception for file operations
import java.io.FileReader; // filereader for buffered reader
import java.io.FileWriter; // file writer for buffered writer
import java.io.IOException; // ioexception for the readline method

/**
*
* @author Shivakumar
*/
public class Bold {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
// TODO code application logic here
BufferedWriter bw=new BufferedWriter(new FileWriter("H:/new.txt")); // Creating buffered Writer object for file //new.txt observe the location
BufferedReader br=new BufferedReader(new FileReader("H:/itemdef.txt")); // BufferedReader object to read //the file
String line;
System.out.printf("%100s ", "January"); // checking for the boldness in multiple ways   
System.out.println((char)27 +"u001B[1m testing bold"); //printing bold text
String textInBold = "Java_Prof_Level";
System.out.print("" + textInBold);
String check; // String to check weather the bold or not
while((line=br.readLine())!=null) // reading file till the last line
{
check=""+line; // escaping character sequance for the boldness of text
if(line.equals(check)); // checking the boldness of the check
{
bw.write(line); // if text is in bold writing into file named new.txt
bw.write(" "); // Entering into new line in the new file
}
  
  
}
}
  
}

//