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

Define a public static method named s2f that takes two String arguments, the name of a file and some text. The method creates th

e file and writes the text to it. If all goes well the method returns true. If, however, either of its arguments are null or if there is any problem in creating or writing to the file, the method returns false.
Engineering
1 answer:
marin [14]3 years ago
7 0

Answer:

import java.io.IOException;

import java.io.PrintWriter;

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class WriteFile {

public static boolean s2f(String fileName,String content)

{

boolean result = true;

if(content == null || fileName == null)

result = false;

else

{

try{

PrintWriter fileWriter = new PrintWriter(fileName, "UTF-8");

fileWriter.println(content);

fileWriter.close();

} catch (IOException e) {

result = false;

}

}

return result;

}

public static void main(String[] args)

{

boolean res = s2f("data.txt","Java is awesome.");

if(res==true)

System.out.println("Successful");

else

System.out.println("There was some error in writing to a file.");

}

}

You might be interested in
An alloy has a yield strength of 818 MPa and an elastic modulus of 104 GPa. Calculate the modulus of resilience for this alloy [
crimeas [40]

Answer:

Modulus of resilience will be 3216942.308j/m^3

Explanation:

We have given yield strength \sigma _y=818MPa

Elastic modulus E = 104 GPa

We have to find the modulus

Modulus of resilience is given by

Modulus of resilience =\frac{\sigma _y^2}{2E}, here \sigma _y is yield strength and E is elastic modulus

Modulus of resilience =\frac{(818\times 10^6)^2}{2\times 104\times 10^9}=3216942.308j/m^3  

5 0
3 years ago
Holmes owns two suits: one black and one tweed. He always wears either a tweed suit or sandals. Whenever he wears his tweed suit
vazorg [7]

Answer:

He wore his black suit, another color of shirt (not purple) and shoes

Explanation:

Holmes owns two suits: one black and one tweed.

Whenever he wears his tweed suit and a purple shirt, he chooses not to wear a tie and whenever he wears sandals, he always wears a purple shirt.

So, if he wore a bow tie yesterday, it means he wore his black suit, another color of shirt (not purple) and shoes because the shirt color is not purple

4 0
3 years ago
To put out a class D metal fire, you must _______ the fire.
gladu [14]

To put out a class D metal fire, you must smother the fire and eliminate the oxygen element in the fire.

<h3>What is a Class D fire?</h3>

A class D fire is a type of fire that cannot be extinguished by water. This is because adding water to it reacts with other elements in the fire intensifying the fire even more.

Smothering in this context involves adding a solution like carbon dioxide (CO2) into the fire, this results in a reduction of oxygen in the atmosphere surrounding the class D fire.

By so doing, smothering the fire eliminates the oxygen element in the fire, thereby extinguishing the fire.

You can learn more about extinguishing fires here https://brainly.in/question/760550

#SPJ1

7 0
2 years ago
What is a motor cycle motor made out of
Natali5045456 [20]

Explanation:

a motorcycle Motor is made out of iron

4 0
3 years ago
Read 2 more answers
Steep safety ramps are built beside mountain highway to enable vehichles with fedective brakes to stop safely. a truck enters a
Veronika [31]

Answer:

a. 6 seconds

b. 180 feet

Explanation:

Images attached to show working.

a. You have the position of the truck so you integrate twice. Use the formula and plug in the time t = 7 sec. Check out uniform acceleration. The time at which the truck's velocity is zero  is when it stops.

b. Determine the initial speed. Plug in the time calculated in the previous step. From this we can observe that the truck comes to a stop before the end of the ramp.

7 0
3 years ago
Other questions:
  • First step in solving frames in to solve support reactions when looking at the frame as a whole. a)- True b)-False
    9·1 answer
  • If a building is too humid, what harmful substance may be stored there?
    13·2 answers
  • Sophia is designing a new welding shop for the local high school. Where should the compressed gas and fuel cylinders be stored?
    15·1 answer
  • Transcription machinery assembles at _______________.
    6·1 answer
  • 3 MAOP stands for which of the following?
    9·1 answer
  • At least 1 sources must be from an organization website (.org) and 1 source must be from and educational website .edu) Do not us
    7·1 answer
  • The example of using biotechnology in heart surgery is used to illustrate which of the
    12·1 answer
  • Use the map to answer the question.
    12·1 answer
  • You may wonder who the rest goes
    11·1 answer
  • Instructions: For each problem, identify the appropriate test statistic to be use (t test or z-test). Then compute z or t value.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!