mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix issue#503
This commit is contained in:
@@ -7,6 +7,7 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* 基本类型的getter接口<br>
|
* 基本类型的getter接口<br>
|
||||||
* 提供一个统一的接口定义返回不同类型的值(基本类型)<br>
|
* 提供一个统一的接口定义返回不同类型的值(基本类型)<br>
|
||||||
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
public interface BasicTypeGetter<K> {
|
public interface BasicTypeGetter<K> {
|
||||||
@@ -14,6 +15,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Object属性值
|
* 获取Object属性值
|
||||||
|
*
|
||||||
* @param key 属性名
|
* @param key 属性名
|
||||||
* @return 属性值
|
* @return 属性值
|
||||||
*/
|
*/
|
||||||
@@ -119,6 +121,7 @@ public interface BasicTypeGetter<K> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Date类型值
|
* 获取Date类型值
|
||||||
|
*
|
||||||
* @param key 属性名
|
* @param key 属性名
|
||||||
* @return Date类型属性值
|
* @return Date类型属性值
|
||||||
*/
|
*/
|
||||||
|
@@ -297,6 +297,19 @@ public class Dict extends LinkedHashMap<String, Object> implements BasicTypeGett
|
|||||||
return super.get(key);
|
return super.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得特定类型值
|
||||||
|
*
|
||||||
|
* @param <T> 值类型
|
||||||
|
* @param attr 字段名
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 字段值
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public <T> T getBean(String attr) {
|
||||||
|
return get(attr, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得特定类型值
|
* 获得特定类型值
|
||||||
*
|
*
|
||||||
|
@@ -3,6 +3,7 @@ package cn.hutool.core.swing;
|
|||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.util.URLUtil;
|
import cn.hutool.core.util.URLUtil;
|
||||||
@@ -31,9 +32,19 @@ public class DesktopUtil {
|
|||||||
* @param url URL地址
|
* @param url URL地址
|
||||||
*/
|
*/
|
||||||
public static void browse(String url) {
|
public static void browse(String url) {
|
||||||
|
browse(URLUtil.toURI(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用平台默认浏览器打开指定URI地址
|
||||||
|
*
|
||||||
|
* @param uri URI地址
|
||||||
|
* @since 4.6.3
|
||||||
|
*/
|
||||||
|
public static void browse(URI uri) {
|
||||||
final Desktop dsktop = getDsktop();
|
final Desktop dsktop = getDsktop();
|
||||||
try {
|
try {
|
||||||
dsktop.browse(URLUtil.toURI(url));
|
dsktop.browse(uri);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@@ -285,7 +285,7 @@ public class JschUtil {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new IORuntimeException(e);
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
throw new IORuntimeException(e);
|
throw new JschRuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
IoUtil.close(in);
|
IoUtil.close(in);
|
||||||
close(channel);
|
close(channel);
|
||||||
|
Reference in New Issue
Block a user