[Solved] This code is showing errors.What is wrong with this code? [duplicate]


It is asking you to handle the Exceptions that are being thrown from the methods that you have used.

Surround them in a try catch block.

public void method(){
        try {
            File file = new File("D:/projects/tFile.txt") ;
            file.createNewFile();
            FileOutputStream fout = new FileOutputStream(file);
            String s = "IPL is very entertaining tournament";
            byte []b = s.getBytes();
            fout.write(b);;
            fout.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

13

solved This code is showing errors.What is wrong with this code? [duplicate]