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
ankoles [38]
3 years ago
13

Given a Scanner reference variable named input that has been associated with an input source consisting of a sequence of lines,

write the code necessary to read in every line and print them all out on a single line, separated by a space.Hint: Use input.nextLine() to read a line and use input.hasNextLine() to test if the input has a next line available to read.
Computers and Technology
1 answer:
Ratling [72]3 years ago
3 0

Answer:

Explanation:

Code

import java.util.Scanner;

public class FileReader{

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

      Scanner scanner = new Scanner(new FileInputStream(new File("D:/input.txt")));

      String output="";

      while(scanner.hasNextLine()){

          output+=scanner.nextLine()+" ";

      }

      System.out.println(output);

  }

}

Code Explanation

Create scanner object by passing file input stream which will read file as input.

Then declare a string variable which will cancatinate the file text into single line util we don't have any other input from scanner.

Then print that output.

Input File

Hello this is dummy

file.

happy holidays

bye

Output

Hello this is dummy file. happy holidays bye

You might be interested in
What defines "print media"? It is media that includes words and text rather than video, such as many blogs. It is media that is
uranmaximum [27]

Answer:

"It is media that is distributed in paper form, such as magazines and newspapers."

3 0
3 years ago
The following code should take a number as input, multiply it by 8, and print the result. In line 2 of the code below, the * sym
Juli2301 [7.4K]

Answer:

num = int(input("enter a number:"))

print(num * 8)

Explanation:

num is just a variable could be named anything you want.

if code was like this num = input("enter a number:")

and do a print(num * 8)

we get an error because whatever the user puts in input comes out a string.

we cast int() around our input() function to convert from string to integer.

therefore: num = int(input("enter a number:"))

will allow us to do  print(num * 8)

6 0
3 years ago
Technician A says that temperature sensors decrease in resistance as the temperature​ increases; this is called positive tempera
Reika [66]

Answer:

Technician B.

Explanation:

The claim of technician B that some vehicle manufacturers use a stepped ECT circuit inside the PCM to broaden the accuracy of the sensor is correct.

6 0
3 years ago
A spreadsheet is an interactive computer program used for
aksik [14]
Making charts, files that need complicated calculations
5 0
2 years ago
Edhesive 9.10 Question 3
Ede4ka [16]

Answer:

your on unit 9 of edhesive?

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • What is the function of the keyboard shortcut Ctrl+Shift+E in a word processor
    5·2 answers
  • You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
    9·2 answers
  • In what year was google launched on the web?
    14·1 answer
  • How might an engineer test a computer chair for comfort?
    10·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • How much a T-mobile plan cost​
    11·2 answers
  • When troubleshooting firewalls, you should never attempt to repeat the problem because you could do more damage. T/F
    6·1 answer
  • Robert works in a call center and receives a call from Kathy. Kathy says she can no longer access the online reporting applicati
    13·1 answer
  • In a Java Script language. create a two-dimension array consisting of numbers representing costs. After creating the array, prin
    11·1 answer
  • In the 1880’s advancements in technology and processes made photography available to the general public. Who is considered the m
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!