Saturday, 7 May 2022

Read text file

             public String readFile(String filePath) throws IOException {

File file = new File(filePath);


BufferedReader br = new BufferedReader(new FileReader(file));


String st;

                String stringOutput="";

while ((st = br.readLine()) != null) {

stringOutput = stringOutput +st;

}

return stringOutput;

}

No comments:

Post a Comment

Switch case in Java

 Problem statement: Return the capital of a state based on input state          public String getCapital(String state){               switch...