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
A reservoir is 1 km wide and 10 km long and has an average depth of 100m. Every hour, 0.1% of the reservoir's volume drops throu
Ksju [112]

Answer:

250.7mw

Explanation:

Volume of the reservoir = lwh

Length of reservoir = 10km

Width of reservoir = 1km

Height = 100m

Volume = 10x10³x10³x100

= 10⁹m³

Next we find the volume flow rate

= 0.1/100x10⁹x1/3600

= 277.78m³/s

To get the electrical power output developed by the turbine with 92 percent efficiency

= 0.92x1000x9.81x277.78x100

= 250.7MW

7 0
3 years ago
While discussing what affects the amount of pressure exerted by the brakes: Technician A says that the shorter the line, the mor
harina [27]

Answer:

Only Technician B is right.

Explanation:

The cylindrical braking system for a car works through the mode of pressure transmission, that is, the pressure applied to the brake pedals, is transmitted to the brake pad through the cylindrical piston.

Pressure applied on the pedal, P(pedal) = P(pad)

And the Pressure is the applied force/area for either pad or pedal. That is, P(pad) = Force(pad)/A(pad) & P(pedal) = F(pedal)/A(pedal)

If the area of piston increases, A(pad) increases and the P(pad) drops, Meaning, the pressure transmitted to the pad reduces. And for most cars, there's a pressure limit for the braking system to work.

If the A(pad) increases, P(pad) decreases and the braking force applied has to increase, to counter balance the dropping pressure and raise it.

This whole setup does not depend on the length of the braking lines; it only depends on the applied force and cross sectional Area (size) of the piston.

5 0
2 years ago
When removing a diesel engine from a truck, Technician A says it is OK to disconnect an air con­ditioning hose, but the refriger
agasfer [191]

Answer:

Technician B is right.

Explanation:

Air conditioning refrigerant contains Freon R22 and R410a, which have been linked to environmental damages, including ozone depletion, global warming, and energy-inefficiency.  For environmentally-savvy entities and individuals, there is the modern move to a more environment-friendly refrigerant, known as R-32.   Technician A's advice to vent the refrigerant outside the shop is in bad taste.  He does not seem to be aware of the environmental footprint of such an action.  Venting gas outside, in addition to the environmental damages, is also a waste of resources, and therefore, costly.  This is why Technician B's advice should be preferred.

5 0
3 years ago
Two streams of air enter a control volume: stream 1 enters at a rate of 0.05 kg / s at 300 kPa and 380 K, while stream 2 enters
alex41 [277]

Answer:

0.08kg/s

Explanation:

For this problem you must use 2 equations, the first is the continuity equation that indicates that all the mass flows that enter is equal to those that leave the system, there you have the first equation.

The second equation is obtained using the first law of thermodynamics that indicates that all the energies that enter a system are the same that come out, you must take into account the heat flows, work and mass flows of each state, as well as their enthalpies found with the temperature.

 

finally you use the two previous equations to make a system and find the mass flows

I attached procedure

5 0
3 years ago
Does a food market have any rooms in particular? Also whats units?
makkiz [27]

Answer:

to be or not to be

Explanation:

Vivi is a drummer for a band. She burns 756756756 calories while drumming for 333 hours. She burns the same number of calories each hour.

8 0
3 years ago
Read 2 more answers
Other questions:
  • A commercial refrigerator with refrigerant -134a as the working fluid is used to keep the refrigerated space at -30C by rejectin
    10·3 answers
  • A bridge to be fabricated of steel girders is designed to be 500 m long and 12 m wide at ambient temperature (assumed 20°C). Exp
    9·1 answer
  • An AC sine wave has an effective value of 100V what’s the peak value of the waveform
    6·1 answer
  • A company specification calls for a steel component to have a minimum tensile strength of 1240 MPa. Tension tests are conducted
    7·1 answer
  • A process involves the removal of oil and other liquid contaminants from metal parts using a heat-treat oven, which has a volume
    10·1 answer
  • Explain why the scenario below fails to illustrate an understanding of the importance of metrology. Situation: Natalie is a cali
    6·1 answer
  • What is name for grandmother in German?
    14·1 answer
  • A closed, rigid tank is filled with a gas modeled as an ideal gas, initially at 27°C and gauge pressure of 300 kPa. The gas is h
    9·1 answer
  • For somebody
    12·1 answer
  • A. How is a decision matrix useful during the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!