Question: The example below is that I got a number 6/7 from the fractions.txt and I split the numerator(6) and denominator(7). Then I save it to

The example below is that I got a number 6/7 from the fractions.txt and I split the numerator(6) and denominator(7). Then I save it to a terminal.txt. Then I want to read 6 and 7 from terminal.txt. How to do that?

I got some problem with my coding. Can you fix it for me?

import java.util.Scanner; import java.io.FileInputStream; import java.io.PrintWriter; import java.io.FileOutputStream; import java.io.FileNotFoundException; public class test { public static void main(String[]args){

Scanner inputStream = null; PrintWriter outputStream = null; try{ inputStream = new Scanner( new FileInputStream ("fractions.txt")); outputStream = new PrintWriter (new FileOutputStream("terminal.txt")); } catch (FileNotFoundException e){ System.out.println("File not found."); System.exit(0); } String data; int count=0; while (inputStream.hasNextLine()){ data = inputStream.nextLine(); count++; System.out.println(data); System.out.println(count); for(String w:data.split("/",0)){ outputStream.println(w); } } Scanner inputStream1 = null; try{ inputStream1 = new Scanner( new FileInputStream ("terminal.txt")); } catch (FileNotFoundException e){ System.out.println("File not found."); System.exit(0); } int [] denominator = new int [count]; int [] numerator = new int [count]; int i=0; int j=0; do { if (inputStream1.hasNextLine()){ numerator [i++] = inputStream1.nextInt(); denominator [j++] = inputStream1.nextInt();} }while (i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!