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
exis [7]
3 years ago
9

Create a file with a 20 lines of text and name it "lines.txt". Write a program to read this a file "lines.txt" and write the tex

t to a new file, "numbered_lines.txt", that will also have line numbers at the beginning of each line. Example: Input file: "lines.txt" Line one Line two Expected output file: 1 Line one 2 Line two
Computers and Technology
1 answer:
ehidna [41]3 years ago
6 0

Answer:

The code has been developed in JAVA as it is the best feasible concept to handle the files.

CODE :

import java.io.*;

public class textEditor { // main class that has the code

    public static void main(String[] args) { // main driver method

       try {

            int count = 0; // count to print the line numbers to the output file

           BufferedReader br = new BufferedReader(new FileReader("lines.txt")); // reading the data from the source text file

           File outfile = new File("numbered_lines.txt"); // creating a file in the output directory

           FileWriter fw = new FileWriter(outfile.getAbsoluteFile()); // initialising the filewriter class to write the data

           BufferedWriter bw = new BufferedWriter(fw); // appending the bufferedwriter to get the data to the output file

           String line; // temporary string value

       

           if (!outfile.exists()) { // if file doesnt exists, then create it

               outfile.createNewFile();

           }

         

           while ((line = br.readLine()) != null){ // iterating over the total line in the source file

               count++;

               bw.write(count +" "+ line); // writing the source data with the line numbers to the output file

               bw.write("\n");

           }        

           bw.close(); // closing the file

           System.out.println("Process Done"); // prompt for the user

       } catch (IOException e) { // catching if any exception is raised

           e.printStackTrace();

       }

   }

}

Explanation:

You might be interested in
I just wanna know how many times a day y'all hit the tutor button at the bottom
vladimir2022 [97]

Answer:

614 x

Explanation:

8 0
3 years ago
Read 2 more answers
The default ____ for a hyperlink is the folder location and the name of the file to which you will link.
ycow [4]
Title is used
hope it helps
6 0
4 years ago
Why does Linux make use of tasklets (i.e., software interrupts) instead of executing all interrupt-related activity in the (hard
Eddi Din [679]

Answer:

Although some devices can be controlled using nothing but their I/O regions, most real devices are a bit more complicated than that. Devices have to deal with the external world, which often includes things such as spinning disks, moving tape, wires to distant places, and so on. Much has to be done in a time frame that is different from, and far slower than, that of the processor. Since it is almost always undesirable to have the processor wait on external events, there must be a way for a device to let the processor know when something has happened.

That way, of course, is interrupts. An interrupt is simply a signal that the hardware can send when it wants the processor's attention. Linux handles interrupts in much the same way that it handles signals in user space. For the most part, a driver need only register a handler for its device's interrupts, and handle them properly when they arrive. Of course, underneath that simple picture there is some complexity; in particular, interrupt handlers are somewhat limited in the actions they can perform as a result of how they are run.

5 0
3 years ago
What is focus of developers interested in the internet of things?
Delicious77 [7]
Investigates the current state of the Internet of things
Explore the opportunities arising for developers
Analyze the quantity and quality of support for developers in this space
Uncover best practices of which developers should have an immediate working knowledge
8 0
3 years ago
Someone please explain me this​
Ipatiy [6.2K]

Answer:

2×4×6×8× your body

Explanation:

your pottery × 2×4×6×8×10

7 0
3 years ago
Other questions:
  • Write a program to output the following quote by Edsger W. Dijkstra: "Computer Science is no more about computers than astronomy
    9·2 answers
  • For a typically large organization how many dns servers should you install
    5·1 answer
  • Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB
    12·1 answer
  • Consumers’ ability to ""time shift"" programs using DVRs and Internet video and other situations that lack simultaneity is an ex
    6·1 answer
  • What do people in japan use to make anime
    5·1 answer
  • What does it mean for a design to be content driven
    12·1 answer
  • You've been hired as a consultant to help an online store owner. You need to complete the implementation of conversion tracking
    6·1 answer
  • This morning when Paul turned on his computer at work, it would not boot. Instead, Paul reported that he heard a loud clicking n
    12·1 answer
  • How are XY coordinates utilized in construct ?
    15·1 answer
  • Does unturned game is good for low end PC that without graphics card?​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!