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
almond37 [142]
3 years ago
5

Public class Question4

Computers and Technology
1 answer:
enyata [817]3 years ago
4 0

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.PrintWriter;

public class Question4 {

/*

* For this exercise you will be doing some basic operations to write to a

* file. You will be creating your very own Secrets of the Universe (TM)

*

* You can use the PrintWriter class to write to files (Chapter 11.4)

*

* Your code should perform the following actions:

*

* 1) Open/Create a file for writing at the following location:

* "files/question4/MySecretsOfTheUniverse.txt" If the file already exists

* you will want to overwrite its contents. 2) Add at least 3 of your own

* secrets of the universe to the file. Each secret should be on its own

* line. 3) Make sure to close your file so that the results are saved.

*

* Note: Your code should not throw any checked exceptions.Note: You will

* need to import some classes from the java.io package.

*/

public static void Question4() {

// creating a File object

File file = new File("files/question4/MySecretsOfTheUniverse.txt");

try {

// opening print writer to write to the file. the file will be

// created if not exist, but you have to ensure that the directory

// files/question4/ exists.

PrintWriter writer = new PrintWriter(file);

// writing three random statements to the file. I dont know anything

// about the secrets of universe you mentioned, so I'm just writing

// some random stuff that came into my mind. You can replace below

// lines with whatever you want to write.

writer.println("Humans are aliens from Mars, sent here to colonize Earth after they screwed up mars.");

writer.println("This universe and everything in it are probably brain cells of some huge cosmic organism.");

writer.println("There may be other forms of life co-exist here on our Earth that we can't see,"

+ " because they vibrate at a different frequency outside of all our measurements");

//closing file, saving changes

writer.close();

} catch (Exception e) {

//printing error if exception is occurred.

System.err.println(e);

}

}

public static void main(String[] args) {

Question4();

}

}

You might be interested in
Hola, alguien me puede ayudar¡¡¡¡¡¡¡¡¡¡¡¡
WARRIOR [948]
Hola<span>, </span>Alguien me<span> podría </span>ayudar<span> a realizar una buena sinopsis de la película "</span><span>Jardín de Amapolas" dirigida por Carlos Melo Guevara, gracias? i hope i helped you</span>
4 0
3 years ago
______ data is data that has not been processed for use. Multiple choice question. Raw Fast Decision Source
Illusion [34]

Answer: Raw Data

Explanation:

Raw data (sometimes called source data, atomic data or primary data) is data that has not been processed for use.

6 0
2 years ago
How to recover permanently deleted photos on iphone 11?
grandymaker [24]

Answer:

Look in your recently deleted album and if it is not there try checking your iCloud, if its not there then it's sadly probably gone forever.

Explanation:

7 0
3 years ago
Name a software program?​
Tju [1.3M]

Answer:

mathematica ,is a software program helps to solve maths equation ...

Explanation:

mark me as brainliest ❤️

6 0
3 years ago
What is the meaning of website cookies? brief explanation ​
Dvinal [7]

Answer: Cookies are messages that web servers pass to your web browser when you visit Internet sites

7 0
3 years ago
Read 2 more answers
Other questions:
  • How do IT security workers help business
    5·1 answer
  • This activity will help you meet these educational goals:
    7·2 answers
  • Which member of the restaurant and food/beverage service career is mostly likely to plan menus and direct worker
    6·2 answers
  • ANSWER QUICKLY!
    10·1 answer
  • 3. Before you get ready to go diving, you want to explore the area. You see a small snowpack across a small bridge, a short walk
    11·1 answer
  • You've formatted the first paragraph of a document. What button can you use to apply the formatting from the first paragraph to
    6·1 answer
  • The velocity dimension of Big Data refers to _____.
    15·1 answer
  • How do you check how much space is left in current drive?
    9·1 answer
  • Vannevar Bush imagined a desktop computing machine that would allow people to access data stored in various information centers
    13·1 answer
  • Which artificial intelligence term is used to describe extracting information from unstructured text.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!