1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ksju [112]
3 years ago
5

You coded the following class:

Computers and Technology
1 answer:
Oxana [17]3 years ago
8 0

Answer:

The code above tries to read a file using the scanner class in java programming language.

But it was done properly.

First, the scanner class library is not imported to the program.

Second,the syntax used in this program is an invalid way of reading a file in java programming language using the scanner class.

Lastly, "String s = file.nextLine();" is not a proper way of reading each line

To correct this problem; use the following code;

import java.util.Scanner;

import java.io.File;

import java.io.FileNotFoundException;

public class ReadFileWithScanner {

try

{

public static void main(String args[]) throws FileNotFoundException {

File text = new File("data.txt");

Scanner file = new Scanner(text);

int lines = 1;

while(file.hasNextLine()){

String line = filw.nextLine();

System.out.println("line " + lines + " :" + line);

lines++;

}

catch (ArithmeticException ae)

{

System.out.println(ae.getMessage());

}

}

}

You might be interested in
Draw the final structure that will house the electronic system​
Natasha_Volkova [10]

Answer:

1. TECHNOLOGY GRADE 9 TERM 3. In this chapter, you will revise the work you did on electrical systems and control

Explanation:Circuits can be found in just about every electronic device you ... An electric circuit is in many ways similar to your circulatory system

4 0
3 years ago
A goal should be___.
Luda [366]

Answer:

D

Explanation:

5 0
3 years ago
Read 2 more answers
Evaluate each condition as to whether it is true or not.
ivann1987 [24]

Answer:

For the first one you have not met those requirements because you are still 16, for the second one you have met those requirements because you can either have a score over 30 (which you have 34) or be a valedictorian

Explanation:

Above

7 0
3 years ago
What happens to the Menu Bar when the<br> object (image, shape, etc.) is "active"?
nexus9112 [7]

Answer: Ok so Sorry about this but I will answer thing at 10:20 tommorow I promise

Explanation:

5 0
2 years ago
which of the following is acomputer program that detects, prevents. and takes action sto deactivate or remove malicious programm
Len [333]

Answer:

antivirus software is the answer to prevent computer from malicious program

8 0
2 years ago
Other questions:
  • How to copy and paste using keyboard onchromebook?
    11·1 answer
  • Best value supply chains strive to excel along four measures: speed, quality, cost, and flexibility. Group of answer choices Tru
    10·1 answer
  • How do you restore deleted notpad++ file?
    12·1 answer
  • Which data type stores images and audio visual clips?
    9·2 answers
  • (Complete the Problem-Solving discussion in Word for Programming Challenge 2 on page 404. Your Problem-Solving discussion should
    13·1 answer
  • You want to allow members of the users group to use fdisk on the /dev/sda drive (and only that drive) and to use the yum command
    14·1 answer
  • Which software programs should students avoid using to create and submit course work? (Choose all that apply). Word, Pages, Numb
    13·1 answer
  • Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar. What will be the ou
    14·1 answer
  • What is the output for the following program?
    6·1 answer
  • What does data warehousing allow organizations to achieve?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!