import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class HelloWorld {
private static final String fname = "input.txt";
public static void main(String[] args) {
// defining readers to
red
BufferedReader b = null;
FileReader f = null;
try {
f = new FileReader(fname);
b = new BufferedReader(f);
String line;
b = new BufferedReader(new FileReader(fname));
// reading file line by line
while ((line = b.readLine()) != null) {
System.out.println(line);
}
}
// if excepitons is caught, printing the trace
catch (IOException e) {
e.printStackTrace();
} finally {
try {
// closing the opened
readers
if (b != null)
b.close();
if (f != null)
f.close();
}
// this is for catching the exception.
catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
Write a program in Java which accepts Input from File and provides output on screen.
java Program Write a program called Copy that accepts the names of an input file and an output file on the command line and copies the contents of the input file to the output file, for example, csc$ java Copy infile.txt outfile.txt
java Write a program called Copy that accepts the names of an input file and an output file on the command line and copies the contents of the input file to the output file, for example, csc$ java Copy infile.txt outfile.txt
Write a complete java program that accepts input from the user, strips any spaces or punctuation then sorts the characters of the input and outputs the sorted characters. For example, input is "I Love Java!" would output "aaeIJLovv"
Write a program in Java that reads the file and does two things: Write to an output file called dataSwitch.txt the same data from the input file, but switch the order of the data entries on each line. For example, if the first line of the input file is “90001 57110”, the first line of the output file would be “57110 90001”. Additionally, print to the screen the number of lines in the file with a label
Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.
Write a Java program that has a method called arrayAverage that accepts an arrary of numbers as an argument and returns the average of the numbers in that array. Create an array to test the code with and call the method from main to print the average to the screen. The array size will be from a user's input (use Scanner). - array size = int - avergage, temperature = double - only method is arrayAverage Output:
FOR JAVA Write a program that takes two command line arguments: an input file and an output file. The program should read the input file and replace the last letter of each word with a * character and write the result to the output file. The program should maintain the input file's line separators. The program should catch all possible checked exceptions and display an informative message. Notes: This program can be written in a single main method Remember that...
In Java code Write a complete method name convertFile that accepts a File object representing an input text file and a PrintWriter objects as arguments. The method should read the contents of the input file and change all characters to uppercase and store the results in the output file.
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...
java program: Write a program which displays the following list on the screen and asks the user to enter either 1 or 2 and perform one of the operations based on the user’s input. If the user enters any other character other than 1 or 2 then display “wrong choice”. LIST OF OPERATIONS 1. Buzz Number 2. Consecutive Odd numbers Note: A BUZZ number is a number which either ends with 7 or is divisible by 7. Sample input 27...