黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

Guava教程

Guava Throwable類

Throwable類提供了相關的Throwable接口的實用方法。

類聲明

以下是com.google.common.base.Throwables類的聲明:

public final class Throwables
? ?extends Object

類方法

繼承的方法

這個類繼承了以下類方法:java.lang.Object

Throwables示例

創建使用所選擇的任何編輯器下面的java程序,比如 C:/> Guava
GuavaTester.java

import java.io.IOException;

import com.google.common.base.Objects;
import com.google.common.base.Throwables;

public class GuavaTester {
   public static void main(String args[]){
      GuavaTester tester = new GuavaTester();
      try {
         tester.showcaseThrowables();
      } catch (InvalidInputException e) {
         //get the root cause
         System.out.println(Throwables.getRootCause(e));
      }catch (Exception e) {
         //get the stack trace in string format
         System.out.println(Throwables.getStackTraceAsString(e));				
      }

      try {
         tester.showcaseThrowables1();			
      }catch (Exception e) {
         System.out.println(Throwables.getStackTraceAsString(e));				
      }
   }

   public void showcaseThrowables() throws InvalidInputException{
      try {
         sqrt(-3.0);			
      } catch (Throwable e) {
         //check the type of exception and throw it
         Throwables.propagateIfInstanceOf(e, InvalidInputException.class);		
         Throwables.propagate(e);
      }	
   }

   public void showcaseThrowables1(){
      try {			
         int[] data = {1,2,3}; 
         getValue(data, 4);			
      } catch (Throwable e) {        
         Throwables.propagateIfInstanceOf(e, IndexOutOfBoundsException.class);		
         Throwables.propagate(e);
      }	
   }

   public double sqrt(double input) throws InvalidInputException{
      if(input < 0) throw new InvalidInputException();
      return Math.sqrt(input);
   }

   public double getValue(int[] list, int index) throws IndexOutOfBoundsException {
      return list[index];
   }

   public void dummyIO() throws IOException {
      throw new IOException();
   }
}

class InvalidInputException extends Exception {
}

驗證結果

使用javac編譯器編譯如下類

C:\Guava>javac GuavaTester.java

現在運行GuavaTester看到的結果

C:\Guava>java GuavaTester

看到結果

InvalidInputException
java.lang.ArrayIndexOutOfBoundsException: 4
?? ?at GuavaTester.getValue(GuavaTester.java:52)
?? ?at GuavaTester.showcaseThrowables1(GuavaTester.java:38)
?? ?at GuavaTester.main(GuavaTester.java:19)

?

 

 

 

 

轉載自并發編程網-ifeve.com

全部教程
主站蜘蛛池模板: 黄色精品在线 | 国产精品1区2区3区在线播放 | 亚洲三级国产 | 一级毛片免费毛片毛片 | 日本污网站 | 精品国产国语对白主播野战 | 国产欧美久久精品 | 国产高清啪啪 | 日韩中文字幕久久久经典网 | 日韩欧美一区二区三区不卡在线 | 日韩成人精品日本亚洲 | 香港一级a毛片在线播放 | 国产日韩欧美在线一二三四 | 国产成人精品亚洲77美色 | 黑人精品videossex黑人 | 91精选视频在线观看 | 曰本女人与动牲交毛片 | 国产精品无卡无在线播放 | 国产尤物二区三区在线观看 | 中文字幕一区二区三区 精品 | 最近更新中文字幕第一页 | 一级毛片在线免费观看 | 在线天堂中文在线网 | 亚洲精品中文字幕久久久久久 | 韩国伦理片在线看免 | aaa国产| 天天操天天擦 | 免费人成在线观看网站品爱网 | 成人叼嘿视频免费网站 | 国产一区在线观看视频 | 翁熄性荡事最新篇王伟忠 | 91视频一区二区三区 | 性三级视频 | www.99热.com| 五月天堂婷婷 | 色综合久久精品中文字幕 | 又黄又爽的美女免费视频 | 国产成人精品999在线观看 | 国内外一级毛片 | 国产亚洲人成网站在线观看 | 国产99视频精品免费观看7 |