Question: CHALLENGE ACTIVITY 3 . 5 . 1 : File output. 5 2 2 5 6 2 3 5 7 8 1 9 4 cul 3

CHALLENGE
ACTIVITY
3.5.1: File output.
5225623578194cul3ray
Jump to level 1
Integer bedCount and string friendName are read from input. A FileOutputStream named fileStream is declared and the file named data txt is opened. Then, a PrintWriter named bedFS is declared and associated with the file. Write the following to the opened file:
"Shopping List:"
"+++"
bedCount, followed by " beds for " and friendName
Another "+++"
End each output with a newline. Finally, close the file.
Ex: If the input is 39zehra, then data txt contains:
Shopping List:
+++
39 beds for zehra
+++
Note: Data written to a file may be lost if the file is not closed.
import java.util. Scanner;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileOutput {
public static void main(String args) throws IOException {
Scanner scnr = new Scanner(
System.in);
FileOutputStream fileStream = null;
PrintWriter bedFS = null;
 CHALLENGE ACTIVITY 3.5.1: File output. 5225623578194cul3ray Jump to level 1 Integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!