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
Namespaces cannot have namespaces as members.<br><br> True<br><br> False
Anna71 [15]

Answer:

False

Explanation:

namespaces can be nested. That is we can have a hierarchy of namespaces.

For examples suppose we have a namespace top. Within this we have another namespace first. At the next level we have a namespace called second. Then we have a class MyClass as a member of this namespace second. Then the complete description of the class will be as follows:

top::first::second::MyClass

5 0
4 years ago
What technology was implemented on apple computer printer ports to facilitate file and printer sharing?
Shtirlitz [24]

A technology which was implemented on Apple computer printer ports to facilitate file and printer sharing is LocalTalk.

<h3>What is a printer?</h3>

A printer can be defined as an electronic output (peripheral) device that is designed and developed for printing paper documents containing texts or images on a computer system.

On Apple computer printer ports, a technology which was implemented to facilitate file and printer sharing is LocalTalk, which is typically implemented based on the physical layer of the AppleTalk networking system.

In this context, we can infer and logically deduce that a technology which was implemented on Apple computer printer ports to facilitate file and printer sharing is LocalTalk.

Read more on printer here: brainly.com/question/17100575

#SPJ1

4 0
2 years ago
The soft-tissue lining of oysters and clams creates pearls. Is a pearl a mineral?
Kisachek [45]
<span>A pearl is not a mineral because it is created artificially. It is a gemstone, not a mineral because it is a composite of mineral Aragonite and a protein compound which is called conchiolin. Pearls are formed by organic and living organisms which is preserved to become a gemstone.</span>
3 0
3 years ago
Read 2 more answers
In your own words, explain what it means to “buy low, sell high.”
Georgia [21]

Answer:

Resell value should be high like buying a used car for a low price fixing it a bit and double your money.

Explanation:

7 0
3 years ago
Read 2 more answers
Four examples of computer virus​
Nikitich [7]

Virus that infects files. Macro Virus is a virus that attaches itself to an executable application. This type of virus is commonly found in Microsoft Word or Excel programs.... Browser Hijacker.... Web Scripting Virus.

Good morning, I hope this helps, and if you don't mind, please mark me as brainliest ❤

4 0
3 years ago
Other questions:
  • Kwan is using JavaScript extensively to add interactivity to his Web site. Contained within his script is a counter object that
    8·1 answer
  • The use of quick styles is a great way to save _____.
    6·1 answer
  • Write a Java program that calculates and prints the monthly pay check for an employee. The net pay is calculated after taking th
    8·1 answer
  • What is the name for unwanted software that installs when you click some links?
    13·2 answers
  • Accessing disk is much slower than accessing memory. As a result, many file systems have been designed with various optimization
    7·1 answer
  • Why vechiles Tyres are black in colour?​
    14·1 answer
  • Copyright ownership analysis starts with this principle: The ________ is the owner.
    6·1 answer
  • SLA:
    14·1 answer
  • Apakah kebaikan mengetahui fungsi elemen pada produk mekatronik​
    5·1 answer
  • Look at (c), is it accurate? ​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!