Recipe 3.11 Surrounding Code with do/for/if/try/while Blocks
You want to enclose a section of code in a try/catch block or in a do/for/if/while construct.
Select the lines to surround, press Ctrl-1 (or select Edit Quick Fix) to list all the possibilities, and select one of them.
Figure 3-14 shows the possibilities that appear when you select code and press Ctrl-l. When you select one of these possibilities, the selected code becomes surrounded with the construct you've chosen .
Figure 3-14. Surrounding code in a block
One of the great things here is that if you surround your code with a try/catch block in this way, Eclipse automatically figures out all the possible exceptions and catches them for you.