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
A TV game show Jeopardy! contestant who uses a strategy to seek out the hidden Daily Double questions, which are usually the thr
jek_recluse [69]

Answer:

Game theory.

Explanation:

In the TV game show Jeopardy! Game theory allows contestant to use a strategy to seek out the hidden Daily Double questions, instead of the more common approach of selecting a single category and selecting questions gradually increasing in the degree of difficulty.

Game theory is the process of using mathematical model in the study of strategic interaction between two or more players in a game or situation having laid down rules and outcomes.

8 0
3 years ago
What is the difference between hollerith and burroughs machine
daser333 [38]

The difference between Hollerith and Burroughs machine is that Hollerith  have a pantograph that is used to create punch cards but the other is different.

<h3>What is a Hollerith machine?</h3>

A Hollerith machine is known to be a kind of a specific type of electromechanical machine that was known to be used as an information-processing resource in all of the early 20th century.

Note that the machine is said to be one that uses a system that has electrical and mechanical signals, and also some set of wires placed over pools of mercury on paper punch cards.

Therefore, The difference between Hollerith and Burroughs machine is that Hollerith  have a pantograph that is used to create punch cards but the other is different.

Learn more about Burroughs machine   from

brainly.com/question/15241347

#SPJ1

6 0
2 years ago
What are the functions of an input device​
marshall27 [118]

Answer:

To feed the computer with data/instructions

6 0
3 years ago
Read 2 more answers
Which of the following is NOT essential for individuals to have to build their own web page?
natali 33 [55]
Linux. You do not need Linux as an operating system for your website.
5 0
4 years ago
A company is completing research and development for software which it is planning to produce in approximately 2 years time. Whi
MrRa [10]

Answer:

true tbh I don't really Know

8 0
3 years ago
Other questions:
  • Which of the following guidelines about forwarding e-mail messages is most appropriate?
    12·2 answers
  • "a web server that is​ specially-built to manage and deliver business intelligence is called a​ _________."
    7·1 answer
  • Create a program to calculate the wage. Assume people are paid double time for hours over 60 a week. Therefore they get paid for
    10·1 answer
  • After you save a table, the new table name appears ____.
    12·2 answers
  • What do customers use to access the internet, usually for a monthly fee?
    6·1 answer
  • Which option allows users to access the handout master to modify it?
    5·1 answer
  • Which of the following rights is NOT guaranteed by copyright?
    11·1 answer
  • In Interactive Charting, which chart type allows you to chart the current spread between a corporate bond and a benchmark govern
    6·1 answer
  • Question 18
    11·1 answer
  • True or false: Because there are so many different network configurations, operating systems, and strategies, it is a challenge
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!