大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

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

全部教程
主站蜘蛛池模板: 日本免费不卡视频 | 日本高清视频一区二区三区 | 成人欧美一区二区三区黑人免费 | 麻豆国产在线不卡一区二区 | 久久久国产亚洲精品 | 国产欧美日韩精品一区二 | 成人青草亚洲国产 | 国产亚洲精品久久久久久牛牛 | 日本中文字幕二区三区 | 久久久香蕉视频 | 国产九九在线视频 | 伊人久久精品午夜 | 九天玄帝诀高清300集免费观看 | 久草热久草在线视频 | 成人日韩精品 | 国产精品人成在线播放新网站 | 国产性生活视频 | 日韩欧美手机在线 | 久久精品系列 | 天天插天天干天天射 | 免费夜色污私人影院网站 | 日韩 欧美 亚洲 中文字幕 | 99久久精品国产片 | 国产精品香蕉在线一区二区 | 亚洲国产精品综合福利专区 | 国产婷婷色综合成人精品 | 97久久人人爽人人爽人人 | 俄罗斯老妇性欧美毛茸茸孕交 | 性欧美暴力猛交xxxxx高清 | 欧美日韩亚洲m码色帝国 | 婷婷综合国产激情在线 | 亚洲福利社 | 自拍视频精品 | 久热精品在线 | 色欧美hdvideosxs4k| 高清欧美一区二区三区 | 亚洲美女激情 | 日韩在线观看一区二区三区 | 久久不雅视频 | 亚洲综合伦理一区 | 日本三级11k影院在线 |