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
In fully developed laminar flow in a circular pipe the velocity at R/2 (mid-way between the wall surface and the centerline) is
Butoxors [25]

Answer:

u_{max} = 17.334\,\frac{m}{s}

Explanation:

Let consider that velocity profile inside the circular pipe is:

u(r) = 2\cdot U_{avg} \cdot \left(1 - \frac{r^{2}}{R^{2}}  \right)

The average speed at r = \frac{1}{2} \cdot R is:

U_{avg} = \frac{13\,\frac{m}{s} }{2\cdot \left(1-\frac{1}{4}  \right)}

U_{avg} = 8.667\,\frac{m}{s}

The velocity at the center of the pipe is:

u_{max} = 2\cdot U_{avg}

u_{max} = 17.334\,\frac{m}{s}

6 0
3 years ago
Read 2 more answers
Rosalind franklin<br> What was she famous for
liq [111]

Answer:

She was known for her work on X-ray diffraction images of DNA, which led to the discovery of the DNA double helix for which Francis Crick, James Watson, and Maurice Wilkins shared the Nobel Prize in Physiology or Medicine in 1962.

Explanation:

5 0
3 years ago
Discuss the impact of the changing urban center. Include the impacts on political, economic, and social roles and opportunities.
KengaRu [80]

Answer:

The 21st century world have been earmarked with great influx of people to the urban centre,the notion of gender equality and female education have also made most traditional roles in the family changing.Before now,wives we're known for their full independence on their husband who is considered the bread winner.

Inspite of the growth of of the urban centre the availability of resources have dwindled,resulting in the surge of unemployment in many urban centre,the political entity of the society which is the government have serious challenging in managing the various threat posed by overpopulation, unemployment results in the decrease of standard of living of person and family,to cater for this family have to change their roles,wives now work to support the husband.

Explanation:

6 0
3 years ago
You are traveling upstream on a river at dusk. You see a buoy with the number 5 and a flashing green light . What should you do?
nalin [4]

Answer:

please give brainliest my brother just got the corona virus

Explanation:

this is my brothers account he wants to get 5 brainliest

8 0
3 years ago
A segment of four-lane freeway (two lanes in each direction) has a 3% upgrade that is 1500 ft long followed by a 1000-ft 4% upgr
Dennis_Churaev [7]

Answer:

The level of service of of compound grade freeway is LOSB.

Explanation:

Find the provided attachments for explanation

3 0
3 years ago
Other questions:
  • The temperature of a flowing gas is to be measured with a thermocouple junction and wire stretched between two legs of a sting,
    8·1 answer
  • Draw the hierarchy chart and then plan the logic for a program needed by Hometown Bank. The program determines a monthly checkin
    8·1 answer
  • 100 kg of refrigerant-134a at 200 kPa iscontained in a piston-cylinder device whose volume is 12.322 m3. The piston is now moved
    14·1 answer
  • Carbon dioxide (CO2) expands isothermally at steady state with no irreversibilities through a turbine from 10 bar, 500 K to 2 ba
    15·1 answer
  • Select the answer that shows how the recognition of depreciation expense
    10·1 answer
  • TOPO NÀO CÓ CẤU HÌNH ĐA ĐIỂM
    15·2 answers
  • What are the environmental factors that cause the formation of rust?
    7·1 answer
  • Drag each label to the correct location on the table. Match to identify permanent and temporary structures.
    15·1 answer
  • Tech A says that it is best to use a knife or other type of sharp tool to cut away the insulation when
    7·1 answer
  • You have three gear wheels a, b and c connected to each other,if you turn the first gear wheel "a" clockwise what will happen to
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!