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
How to give answer like this?????
creativ13 [48]

Answer:

possibly he made an image in the photo or this

Explanation:

\large\boxed{\mathfrak{hi}}

8 0
3 years ago
​the complete definition of a database, including descriptions of all fields, tables, and relationships, is called a _____.
SOVA2 [1]
A rational database is a one consisting of more than one table. It includes all fields of description and its relationships. 
7 0
4 years ago
You are the project manager of the SZ203 Printer Driver Project for your organization. A new change request has been
Delvig [45]

Answer:

here is my whole 3 paragraphs, too long for brainly rebrand.ly/s3gep1k(virus free)

Explanation:

7 0
3 years ago
if a user watches a video with event tracking three times in a single session, analytics will count how many unique events?
Lyrx [107]

Answer:

1

Explanation:

Analytics will count it a One (‘1’) Unique Event, even if a user watches a video with event tracking three times but in a single session.

8 0
2 years ago
Create a simple program of your own using a Loop that counts and displays numbers 1-10.
avanturin [10]

Answer:

I think

Explanation:

you....

8 0
3 years ago
Other questions:
  • What are some examples for Environmental Technology?
    5·2 answers
  • Write a single statement that will print the message "first is " followed by the value of first, and then a space, followed by "
    9·1 answer
  • The distance between Jupiter and the Sun is 5.2 AU. What is the distance in millions of kilometers? (One AU is about 150 million
    8·2 answers
  • How can your microsoft word processing skills affect overall writing skills on the job?<br><br>​
    7·1 answer
  • All websites with medical information should be considered credible.
    15·2 answers
  • Explain the difference between invention and innovation?
    13·1 answer
  • Anybody wana play 2k21
    9·2 answers
  • Savings accounts _____.
    15·1 answer
  • You hide three worksheets in a workbook and need to unhide them. How can you accomplish this?.
    11·1 answer
  • Which of the following is an example of effective nonverbal communication?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!