Please help with this. Text below Using the AssignReadString clasa discussed in
ID: 3796748 • Letter: P
Question
Please help with this. Text below
Using the AssignReadString clasa discussed in ola (215, shown below), add a method. bca230Prerega0. to read the BCS catalog file posted to this ignment and list the title of every BCS oourae whose description mentions BCS 230. implying that BCS 220 is a Guidelines Look at the String indexOf0 method Fut the AssignReadString class in the package named for your last name In the file, each course is represented by a pair of ines, first a title, then a description. The program output should be: BCS 318 FERL Frogramming ECS 340 Ecs 345 JAVA Programming BCS 300 Programming in SQL BCS 370 Data Structures ECS 378 ormation Security BCS 415 Operating System Internals and Design BCS 430W-Senior Project Writing Intensive) Upload Assign Read String java to this assignment. class Assign ReadString void readAndDisplay0 String path fie-path String Bcs345 BCS 345 File file new File(path): FilelnputStream inputstream Buffered Reader null. new FielnputStream(tie) new BufferedReaderinew InputStreamReader(inputstream): while (null (line rdr.readLine0) if (line startsWith(BCS34E) System.out printin(line) line nir readLine0 Syste out printin(line): rdr.close0. System out printin(BCS34 not found 5+" oatoh (IOException iox) System err printin (iox.etMessage0):Explanation / Answer
import java.awt.image.BufferedImageFilter;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.management.Descriptor;
import javax.swing.InputMap;
import org.xml.sax.InputSource;
public class AssignReadString {
void readAndDisplay()
{
String path = "file-path";
String line;
String BCS345 = "BCS 345";
File file = new File(path);
FileInputStream inputStream;
BufferedReader rdr = null;
try
{
inputStream = new FileInputStream(file);
rdr = new BufferedReader(new InputStreamReader(inputStream));
while(null != (line = rdr.readLine()))
{
if (line.startsWith(BCS345))
{
System.out.println(line);
line = rdr.readLine();
System.out.println(line);
rdr.close();
return;
}
}
System.out.println(BCS345 + " not found");
rdr.close();
}
catch(IOException iox)
{
System.err.println(iox.getMessage());
}
}
// this function read catalog file named file-path and print all course title having BCS 230 in their description
void bcs230Prereqs()
{
String path = "file-path";
String line;
String BCS230 = "BCS 230";
File file = new File(path);
FileInputStream inputStream;
BufferedReader rdr = null;
try
{
// creating streams to read file
inputStream = new FileInputStream(file);
rdr = new BufferedReader(new InputStreamReader(inputStream));
// reading file till end
while(null != (line = rdr.readLine()))
{
String title = line;
String decription = rdr.readLine();
// if BCS 230 is in description print title
if (decription.indexOf(BCS230) != -1)
{
System.out.println(title);
}
}
rdr.close();
}
catch(IOException iox)
{
System.err.println(iox.getMessage());
}
}
public static void main(String[] args)
{
AssignReadString asrs = new AssignReadString();
asrs.bcs230Prereqs();
}
}