Ask Question
20 March, 06:21

Define a public static method named f2s that takes a single String argument, the name of a file. The method returns a (concievably very large!) String that is an exact copy of the contents of the file. If the file cannot be opened the method returns null.

+2
Answers (1)
  1. 20 March, 07:00
    0
    public static String f2s (String s) throws IOException {

    File f = new File (s);

    Scanner input = new Scanner (f);

    String ss = "";

    while (input. hasNext ()) {

    ss + = input. nextLine ();

    }

    return ss;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Define a public static method named f2s that takes a single String argument, the name of a file. The method returns a (concievably very ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers