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
Help me with this for brainiest:)
kirza4 [7]
Gsvshhenejwnbbwbdbdhebwn
3 0
3 years ago
A 860 kΩ resistor has 34 μA of current. What is the supply voltage for this electric circuit?
Juliette [100K]

Explanation:

first changing kilo ohm to ohm

860000 = 860 kΩ

and change 34 micro ampare to ampare

34 μA=3.4×10^-5

recalling the equation V=I*R

V= 3.4×10^-5×860000

v=29.24

8 0
3 years ago
Read 2 more answers
A fluid of specific gravity 0.96 flows steadily in a long, vertical 0.71-in.-diameter pipe with an average velocity of 0.90 ft/s
KengaRu [80]

Answer:

0.00650 Ib s /ft^2

Explanation:

diameter ( D ) = 0.71 inches = 0.0591 ft

velocity = 0.90 ft/s ( V )

fluid specific gravity = 0.96 (62.4 )  ( x )

change in pressure ( P ) = 0 because pressure was constant

viscosity =  (change in p - X sin∅ ) D^{2} / 32 V

              = ( 0 - 0.96( 62.4) sin -90 ) * 0.0591 ^2  / 32 * 0.90

              = - 59.904 sin (-90) * 0.0035 / 28.8

              = 0.1874 / 28.8

  viscosity = 0.00650 Ib s /ft^2

8 0
3 years ago
Read 2 more answers
When the Moon is in the position shown, how would the Moon look to an observer on the North Pole?
kirill115 [55]

Answer:

cant see the moon sorry dude

5 0
3 years ago
Adding new equipment or processes may require changes to the PPE requirements for
Yuki888 [10]
I think it’s is false I’m not that sure
5 0
2 years ago
Read 2 more answers
Other questions:
  • Based in bonding theory, explain why heat capacity increases when you consider metals, ceramics and polymers.
    14·1 answer
  • Air is used as the working fluid in a simple ideal Brayton cycle that has a pressure ratio of 12, a compressor inlet temperature
    13·1 answer
  • Oil with a density of 850 kg/m3 and kinematic viscosity of 0.00062 m2/s is being discharged by an 8-mm-diameter, 42-m-long horiz
    9·1 answer
  • The densities of several materials are given in SI units. Convert these to densities in U.S. customary units (slug/ft3), and als
    12·1 answer
  • A proposed piping and pumping system has 20-psig static pressure, and the piping discharges to atmosphere 160 ft above the pump.
    8·1 answer
  • What is meant by the thickness to chord ratio of an aerofoil?
    12·1 answer
  • A circuit contains four 100 ohm resistors connected in series. If you test the circuit with a DMM you should read a total resist
    14·1 answer
  • A rigid vessel with a volume of 10 m3 contains a water-vapor mixture at 400 kPa. If the quality is 60 percent, find the mass. Th
    11·1 answer
  • What are the purpose of studying the strength of materials and testing.
    5·1 answer
  • A building permit allows a builder to?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!