Constructor and Description |
---|
MyInit() |
Modifier and Type | Method and Description |
---|---|
<V> Try.TryCatch<V,X> |
init(Try.CheckedSupplier<V,X> input)
Initialise a try / catch / finally block
Define the variables to be used within the block.
|
Try<java.lang.Void,X> |
run(Try.CheckedRunnable<X> input)
Run the supplied CheckedRunnable and trap any Exceptions
Return type is Void
|
<V> Try<V,X> |
tryThis(Try.CheckedSupplier<V,X> input)
Run the supplied CheckedSupplier and trap the return value or an Exception
inside a Try
|
public <V> Try.TryCatch<V,X> init(Try.CheckedSupplier<V,X> input)
Try.Init
Try.catchExceptions(FileNotFoundException.class,IOException.class) .init(()->new BufferedReader(new FileReader("file.txt"))) .tryWithResources(this::read);or
Try t2 = Try.catchExceptions(FileNotFoundException.class,IOException.class) .init(()->Tuple.tuple(new BufferedReader(new FileReader("file.txt")),new FileReader("hello"))) .tryWithResources(this::read2); private String read2(Tuple2<BufferedReader,FileReader> res) throws IOException{ String line = res.v1.readLine();
public Try<java.lang.Void,X> run(Try.CheckedRunnable<X> input)
Try.Init
public <V> Try<V,X> tryThis(Try.CheckedSupplier<V,X> input)
Try.Init