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
As resistors are added in series to a circuit, the total resistance will
olganol [36]

The equivalent of the resistance connected in the series will be Req=R₁+R₂+R₃.

<h3>
What is resistance?</h3>

Resistance is the obstruction offered whenever the current is flowing through the circuit.

So the equivalent resistance is when three resistances are connected in series. When the resistances are connected in series then the voltage is different and the current remain same in each resistance.

V eq    =    V₁    +    V₂    +    V₃

IReq    =    IR₁    +    IR₂   +    IR₃

Req    =    R₁    +    R₂   +    R₃

Therefore the equivalent of the resistance connected in the series will be Req=R₁+R₂+R₃.

To know more about resistance follow

brainly.com/question/24858512

#SPJ4

8 0
2 years ago
W10L1-Show It: Pythagorean Theorem<br> Calculate the total material in the picture.<br> 4<br> 3
Fantom [35]

Answer:

35

Explanation: I really dont even know, I just used up all my tries on it and got it wrong on every other thing i chose. So it's 35 i believe cause its the only answer i didnt choose.

7 0
3 years ago
If a hoist lifts a 4500lb load 30ft in 15s, the power delivered to the load is a) 18.00hp b) 9000hp c) 16.36hp d) None of the ab
12345 [234]

Answer:

Explanation:

load = 4500lb                   lift height= 30 ft

time =15 s

velocity=\frac{30}{15} ft/s

velocity=2 ft/s

power = force\times velocity

power={4500}\times2

power= 9000 lb ft/s

1 hp= 550 lb ft/s

power= \frac{9000}{550} =16.36 hp

5 0
3 years ago
Cavitation usually occurs because:
IgorLugansk [536]

Answer:

B) the liquid accelerated to high velocities.

<em>I</em><em> </em><em>hope</em><em> </em><em>this helps</em><em> </em>

3 0
3 years ago
Many households in developing countries prepare food over indoor cook stoves with no ducting system to exhaust the combustion pr
lorasvet [3.4K]

Answer:

   C = 0.22857 ng / m³

Explanation:

Let's solve this problem for part the total time in the kitchen is

          t = 2h (60 min / 1h) = 120 min

The concentration (C) quantity of benzol pyrene is the initial quantity plus the quantity generated per area minus the quantity eliminated by the air flow. The amount removed can be calculated assuming that an amount of extra air that must be filled with the pollutant

amount generated

         C = co + time_generation rate / (area_house + area_flow)

         C = 0.2 + 0.01 120 / (40+ 2)

         C = 0.22857 ng / m³

7 0
3 years ago
Other questions:
  • The kinetic energy correction factor depends on the (shape — volume - mass) of the cross section Of the pipe and the (velocity —
    11·1 answer
  • Create a program that calculates the monthly payments on a loan using Decimal &amp; LC Console SEE Sanple Run Attached Specifica
    14·1 answer
  • Who can work on a fixed ladder that extends more than 24 feet?
    11·1 answer
  • A flat-plate solar collector is 2 m long and 1 m wide and is inclined 60o to the horizontal. The cover plate is separated from t
    13·1 answer
  • The jib crane is supported by a pin at Cand rod AB. The rod can withstand a maximum tension of 40 kN. If the load has a mass of
    11·1 answer
  • An insulated tank having a total volume of 0.6 m3 is divided into two compartments. Initially one compartment contains 0.4 m3 of
    8·1 answer
  • Please what is dif<br>ference between building technology and building engineering.​
    14·2 answers
  • Software that is released to have users test out the "bugs" is known as Ransomeware O Break-in software 2 O Flim flam software O
    15·1 answer
  • Describe the greatest power in design according to Aravena?
    15·1 answer
  • Which pipe for water is best for construction?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!