Będę wdzięczny za konkretną pomoc w zrozumieniu i rozwiązaniu tego zadania:)
Pewnych poleceń w zadaniu nie, rozumiem stąd mogę błędnie realizować zadanie.
Z góry wielkie dzięki za pomoc:)
Darek
I will be grateful for specific help in understanding and solving this task :)
Certain commands in the task no, I understand, hence I can mistake the task.
Many thanks in advance for your help :)
Darek
package pl.codegym.task.task09.task0915;
import java.io.CharConversionException;
import java.io.IOException;
import java.nio.file.FileSystemException;
/*
Obsługiwanie zwyczajnych wyjątków
*/
public class Solution
{
public static StatelessBean BEAN = new StatelessBean();
private static Exception exception;
public static void main(String[] args) throws FileSystemException, IOException
{
try {
obslugaExceptions();
} catch (Exception e) {
BEAN.log();
}
}
public static void obslugaExceptions() throws FileSystemException, IOException
{
try {
//BEAN.log();
BEAN.throwExceptions();
} catch (FileSystemException e) {
BEAN.log();
throw e;
} catch (CharConversionException e) {
BEAN.log();
} catch (IOException e) {
BEAN.log();
}
}
public static class StatelessBean
{
public void log(Exception exception)
{
System.out.println(exception.getMessage() + ", " + exception.getClass().getSimpleName());
}
public void throwExceptions() throws CharConversionException, FileSystemException, IOException
{
int i = (int) (Math.random() * 3);
if (i == 0)
throw new CharConversionException();
if (i == 1)
throw new FileSystemException("");
if (i == 2)
throw new IOException();
}
private void log()
{
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
}