本文整理匯總了Java中java.net.URISyntaxException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java URISyntaxException.printStackTrace方法的具體用法?Java URISyntaxException.printStackTrace怎麽用?Java URISyntaxException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.net.URISyntaxException
的用法示例。
在下文中一共展示了URISyntaxException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: contextInitialized
import java.net.URISyntaxException; //導入方法依賴的package包/類
@Override
public void contextInitialized(ServletContextEvent e) {
LOG.info("Creating Smaph context.");
ServletContext context = e.getServletContext();
context.setAttribute("nif-parser", new TurtleNIFDocumentParser());
context.setAttribute("nif-creator", new TurtleNIFDocumentCreator());
String watGcubeToken = context.getInitParameter(WAT_GCUBE_TOKEN);
SmaphBuilder.initialize(watGcubeToken);
try {
context.setAttribute("wikipedia-api", new WikipediaInterfaceWAT.WikipediaInterfaceWATBuilder().gcubeToken(watGcubeToken).build());
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
context.setAttribute("wiki-to-freebase", WikipediaToFreebase.open(context.getInitParameter(FREEBASE_DIR)));
context.setAttribute("entity-to-anchors", EntityToAnchors.fromDB(context.getInitParameter(ENTITY_TO_ANCHORS_DB)));
}
示例2: initCookies
import java.net.URISyntaxException; //導入方法依賴的package包/類
private void initCookies() {
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
if (cookieManager.getCookieStore().getCookies().size() == 0) {
try {
String url = SharedPreferencesEditor.getInstance().getString(
Constants.PREFS_URL_SHORTCUT);
URI uri = new URI(url);
HttpCookie cookie = new HttpCookie(Constants.COOKIE_AUTH_NAME,
SharedPreferencesEditor.getInstance().getString(
Constants.PREFS_AUTH));
cookie.setDomain(uri.getHost());
cookie.setPath(Constants.COOKIE_BASE_PATH);
cookie.setVersion(0);
cookie.setMaxAge((new Date()).getTime()
+ Constants.COOKIE_LIFETIME_YEAR);
cookieManager.getCookieStore().add(uri, cookie);
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
示例3: build
import java.net.URISyntaxException; //導入方法依賴的package包/類
/**
* Creates a URI for the requested api and method
* [bittrex-api-url]/[version]/[api]/[method]
*
* @param api
* API to use
* @param method
* String literal representing the methodname
* @param params
* URI Parameter
* @return Bittrex API URI
*/
public static URI build(String api, String method, Map<String, String> params) {
final URIBuilder builder = new URIBuilder();
builder.setScheme(SCHEME);
builder.setHost(HOST);
builder.setPath(String.format("%s/%s/%s/%s", API_PATH, VERSION, api, method));
if(params == null) {
params = new HashMap<>();
}
for(Entry<String, String> paramEntry : params.entrySet()) {
builder.addParameter(paramEntry.getKey(), paramEntry.getValue());
}
try {
return builder.build();
} catch (URISyntaxException e) {
// Do
e.printStackTrace();
}
return null;
}
示例4: UpdateImgStatus
import java.net.URISyntaxException; //導入方法依賴的package包/類
public static void UpdateImgStatus(String group_id, int status){
Connection connection = null;
PreparedStatement ps = null;
String groupMemberTableName = "img_detect_status";
try{
try {
connection = DbConnection.getConnection();
} catch (URISyntaxException e) {
e.printStackTrace();
}
ps = connection.prepareStatement(
"UPDATE " + groupMemberTableName + " SET status=?" + " WHERE group_id=?"
);
ps.setInt(1, status);
ps.setString(2, group_id);
if(ps.executeUpdate()==1){
System.out.println("Berhasil update imd status : " + status);
}
} catch (SQLException ex){
System.out.println("Gagal update status img detect : " + ex.toString());
} finally {
DbConnection.ClosePreparedStatement(ps);
DbConnection.CloseConnection(connection);
}
}
示例5: queryActivies
import java.net.URISyntaxException; //導入方法依賴的package包/類
private int queryActivies(String url) {
try {
if (mWeakReference.get() == null) {
return 0;
}
Intent intent = new Intent().parseUri(url, Intent.URI_INTENT_SCHEME);
PackageManager mPackageManager = mWeakReference.get().getPackageManager();
List<ResolveInfo> mResolveInfos = mPackageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
return mResolveInfos == null ? 0 : mResolveInfos.size();
} catch (URISyntaxException ignore) {
if (LogUtils.isDebug()) {
ignore.printStackTrace();
}
return 0;
}
}
示例6: invalidPackageOrClass
import java.net.URISyntaxException; //導入方法依賴的package包/類
@Override
protected long invalidPackageOrClass(XmlResourceParser parser) {
final String uri = getAttributeValue(parser, ATTR_URI);
if (TextUtils.isEmpty(uri)) {
return -1;
}
final Intent metaIntent;
try {
metaIntent = Intent.parseUri(uri, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
return -1;
}
ResolveInfo resolved = mPackageManager.resolveActivity(metaIntent,
PackageManager.MATCH_DEFAULT_ONLY);
final List<ResolveInfo> appList = mPackageManager.queryIntentActivities(
metaIntent, PackageManager.MATCH_DEFAULT_ONLY);
// Verify that the result is an app and not just the resolver dialog asking which
// app to use.
if (wouldLaunchResolverActivity(resolved, appList)) {
// If only one of the results is a system app then choose that as the default.
final ResolveInfo systemApp = getSingleSystemActivity(appList);
if (systemApp == null) {
// There is no logical choice for this meta-favorite, so rather than making
// a bad choice just add nothing.
return -1;
}
resolved = systemApp;
}
final ActivityInfo info = resolved.activityInfo;
final Intent intent = mPackageManager.getLaunchIntentForPackage(info.packageName);
if (intent == null) {
return -1;
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
return addShortcut(info.loadLabel(mPackageManager).toString(), intent,
Favorites.ITEM_TYPE_APPLICATION);
}
示例7: openWebsite
import java.net.URISyntaxException; //導入方法依賴的package包/類
/**
* Opens a Website in the Browser
*
* @param url - Target URL
*/
public static void openWebsite(URL url) {
try {
Functions.openWebsite(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
示例8: openWebpage
import java.net.URISyntaxException; //導入方法依賴的package包/類
public static void openWebpage(URL url) {
try {
openWebpage(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
示例9: convertShortcutsToLauncherActivities
import java.net.URISyntaxException; //導入方法依賴的package包/類
/**
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
* launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
*/
@Thunk void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
db.beginTransaction();
Cursor c = null;
SQLiteStatement updateStmt = null;
try {
// Only consider the primary user as other users can't have a shortcut.
long userSerial = getDefaultUserSerial();
c = db.query(Favorites.TABLE_NAME, new String[] {
Favorites._ID,
Favorites.INTENT,
}, "itemType=" + Favorites.ITEM_TYPE_SHORTCUT + " AND profileId=" + userSerial,
null, null, null, null);
updateStmt = db.compileStatement("UPDATE favorites SET itemType="
+ Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?");
final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);
while (c.moveToNext()) {
String intentDescription = c.getString(intentIndex);
Intent intent;
try {
intent = Intent.parseUri(intentDescription, 0);
} catch (URISyntaxException e) {
e.printStackTrace();
continue;
}
if (!Utilities.isLauncherAppTarget(intent)) {
continue;
}
long id = c.getLong(idIndex);
updateStmt.bindLong(1, id);
updateStmt.executeUpdateDelete();
}
db.setTransactionSuccessful();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
db.endTransaction();
if (c != null) {
c.close();
}
if (updateStmt != null) {
updateStmt.close();
}
}
}
示例10: getStringFromURL
import java.net.URISyntaxException; //導入方法依賴的package包/類
public static String getStringFromURL(String url){
if (url!=null && !"".equals(url)) {
try {
URI uri = new URI(url);
url=uri.getPath();
} catch (URISyntaxException e){
e.printStackTrace();
}
}
return url;
}
示例11: init
import java.net.URISyntaxException; //導入方法依賴的package包/類
/**
* This is to be called before any other method of DistributedCacheEmulator.
* <br> Checks if emulation of distributed cache load is needed and is feasible.
* Sets the flags generateDistCacheData and emulateDistributedCache to the
* appropriate values.
* <br> Gridmix does not emulate distributed cache load if
* <ol><li> the specific gridmix job type doesn't need emulation of
* distributed cache load OR
* <li> the trace is coming from a stream instead of file OR
* <li> the distributed cache dir where distributed cache data is to be
* generated by gridmix is on local file system OR
* <li> execute permission is not there for any of the ascendant directories
* of <ioPath> till root. This is because for emulation of distributed
* cache load, distributed cache files created under
* <ioPath/distributedCache/> should be considered by hadoop
* as public distributed cache files.
* <li> creation of pseudo local file system fails.</ol>
* <br> For (2), (3), (4) and (5), generation of distributed cache data
* is also disabled.
*
* @param traceIn trace file path. If this is '-', then trace comes from the
* stream stdin.
* @param jobCreator job creator of gridmix jobs of a specific type
* @param generate true if -generate option was specified
* @throws IOException
*/
void init(String traceIn, JobCreator jobCreator, boolean generate)
throws IOException {
emulateDistributedCache = jobCreator.canEmulateDistCacheLoad()
&& conf.getBoolean(GRIDMIX_EMULATE_DISTRIBUTEDCACHE, true);
generateDistCacheData = generate;
if (generateDistCacheData || emulateDistributedCache) {
if ("-".equals(traceIn)) {// trace is from stdin
LOG.warn("Gridmix will not emulate Distributed Cache load because "
+ "the input trace source is a stream instead of file.");
emulateDistributedCache = generateDistCacheData = false;
} else if (FileSystem.getLocal(conf).getUri().getScheme().equals(
distCachePath.toUri().getScheme())) {// local FS
LOG.warn("Gridmix will not emulate Distributed Cache load because "
+ "<iopath> provided is on local file system.");
emulateDistributedCache = generateDistCacheData = false;
} else {
// Check if execute permission is there for all the ascendant
// directories of distCachePath till root.
FileSystem fs = FileSystem.get(conf);
Path cur = distCachePath.getParent();
while (cur != null) {
if (cur.toString().length() > 0) {
FsPermission perm = fs.getFileStatus(cur).getPermission();
if (!perm.getOtherAction().and(FsAction.EXECUTE).equals(
FsAction.EXECUTE)) {
LOG.warn("Gridmix will not emulate Distributed Cache load "
+ "because the ascendant directory (of distributed cache "
+ "directory) " + cur + " doesn't have execute permission "
+ "for others.");
emulateDistributedCache = generateDistCacheData = false;
break;
}
}
cur = cur.getParent();
}
}
}
// Check if pseudo local file system can be created
try {
pseudoLocalFs = FileSystem.get(new URI("pseudo:///"), conf);
} catch (URISyntaxException e) {
LOG.warn("Gridmix will not emulate Distributed Cache load because "
+ "creation of pseudo local file system failed.");
e.printStackTrace();
emulateDistributedCache = generateDistCacheData = false;
return;
}
}
示例12: uri
import java.net.URISyntaxException; //導入方法依賴的package包/類
private static URI uri(String address) {
try {
return new URI(address);
} catch (URISyntaxException e) {
e.printStackTrace();
return null;
}
}
示例13: startRestServer
import java.net.URISyntaxException; //導入方法依賴的package包/類
public static HttpServer startRestServer() {
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.0");
beanConfig.setTitle("SlideBar REST Interface");
beanConfig.setResourcePackage(RootResource.class.getPackage().getName());
beanConfig.setSchemes(new String[] { "http" });
beanConfig.setHost("localhost:5055");
beanConfig.setScan(true);
final ResourceConfig rc = new ResourceConfig();
rc.packages(RootResource.class.getPackage().getName());
rc.register(LoggingFeature.class);
rc.register(JacksonFeature.class);
rc.register(ApiListingResource.class);
rc.register(SwaggerSerializers.class);
rc.property(ServerProperties.WADL_FEATURE_DISABLE, true);
Logger l = Logger.getLogger("org.glassfish.grizzly.http.server.HttpHandler");
l.setLevel(Level.FINE);
l.setUseParentHandlers(false);
ConsoleHandler ch = new ConsoleHandler();
ch.setLevel(Level.ALL);
l.addHandler(ch);
try {
return GrizzlyHttpServerFactory.createHttpServer(new URI("http://localhost:5055"), rc);
} catch (URISyntaxException e) {
e.printStackTrace();
return null;
}
}
示例14: normalizePercentEncoding
import java.net.URISyntaxException; //導入方法依賴的package包/類
public void normalizePercentEncoding() {
try {
uri = new URI(uri.getScheme(),
uri.getSchemeSpecificPart(),
uri.getFragment());
} catch (URISyntaxException e) {
// This should never be reached
e.printStackTrace();
}
}
示例15: findProxy
import java.net.URISyntaxException; //導入方法依賴的package包/類
/**
* Return a proxy if exist
* @return
* null if no proxy, the InetSocketAddress else of proxy
*/
public static InetSocketAddress findProxy() {
logger.info("detecting proxies");
ProxySearch ps = ProxySearch.getDefaultProxySearch();
ProxySelector myProxySelector = ps.getProxySelector();
ProxySelector.setDefault(myProxySelector);
List<Proxy> l = null;
if(myProxySelector == null) {
logger.info("No Proxy");
return null;
}
try {
l = myProxySelector.select(new URI("https://graph.microsoft.com"));
}
catch (URISyntaxException e) {
e.printStackTrace();
}
if (l != null) {
for (Iterator<Proxy> iter = l.iterator(); iter.hasNext();) {
java.net.Proxy proxy = (java.net.Proxy) iter.next();
logger.info("proxy type: " + proxy.type());
InetSocketAddress addr = (InetSocketAddress) proxy.address();
if (addr == null) {
logger.info("No Proxy");
return null;
}
logger.info("Hostname: " + addr.getHostName());
logger.info("Port : " + addr.getPort());
return addr;
}
}
logger.info("No Proxy");
return null;
}