黑马程序员技术交流社区

标题: 重定位怎么理解 [打印本页]

作者: 进击的蜗牛    时间: 2015-7-19 16:08
标题: 重定位怎么理解
try
                {
                        int[] arr = new int[2];
                        System.out.println(arr[3]);
                }
                catch(Exception e)
                {
                        try
                        {
                                Date d = new Date();
                                //格式化日期
                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                String s = sdf.format(d);
                               
                                PrintStream ps = new PrintStream("exception.log");
                                ps.println(s);
                               
                                //重新定位向ps对象中输出?怎么理解?有和没有没什么区别啊?
             System.setOut(ps);
                               
                        }
                        catch(Exception ex)
                        {
                                throw new RuntimeException("日志文件创建失败");
                        }
                        //e.printStackTrace(System.out);
                        e.printStackTrace();
                }






欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2