本文整理匯總了Java中java.net.URISyntaxException類的典型用法代碼示例。如果您正苦於以下問題:Java URISyntaxException類的具體用法?Java URISyntaxException怎麽用?Java URISyntaxException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
URISyntaxException類屬於java.net包,在下文中一共展示了URISyntaxException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BaseResource
import java.net.URISyntaxException; //導入依賴的package包/類
public BaseResource(URI uri, boolean rewrite) {
if (uri == null) {
throw new IllegalArgumentException("uri must not be null");
}
if (rewrite && "localhost".equals(uri.getHost())) {
// Rewrite localhost URIs to refer to the special Android emulator loopback passthrough interface.
Logger.debug(LOG_TAG, "Rewriting " + uri + " to point to " + ANDROID_LOOPBACK_IP + ".");
try {
this.uri = new URI(uri.getScheme(), uri.getUserInfo(), ANDROID_LOOPBACK_IP, uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment());
} catch (URISyntaxException e) {
Logger.error(LOG_TAG, "Got error rewriting URI for Android emulator.", e);
throw new IllegalArgumentException("Invalid URI", e);
}
} else {
this.uri = uri;
}
}
示例2: addPageObject
import java.net.URISyntaxException; //導入依賴的package包/類
public AbstractPage addPageObject(AbstractPage p) {
String url = p.forUrl();
if(!mapper.containsKey(url)){
mapper.put(url, p);
String currentUrl = null;
try{
String currUrl = driver.getCurrentUrl();
URI url2 = new URI(currUrl);
String path = url2.getPath();
currentUrl = currUrl.substring(0, currUrl.indexOf(path));
}catch (URISyntaxException e) {
e.printStackTrace();
} catch(NullPointerException npe){
currentUrl = baseUrl;
}
p.setBaseUrl(baseUrl.equals(currentUrl) ? baseUrl: currentUrl);
PageFactory.initElements(driver, p);
}
return mapper.get(url);
}
示例3: getPluginName
import java.net.URISyntaxException; //導入依賴的package包/類
private String getPluginName(URL url) {
// url.getPath() works for jar URLs; url.toURI().getPath() doesn't
// because jars aren't considered "hierarchical"
String name = url.getPath();
//remove the '/creole.xml' from the end
name = name.substring(0, name.length() - 11);
//get everything after the last /
int lastSlash = name.lastIndexOf("/");
if(lastSlash != -1) {
name = name.substring(lastSlash + 1);
}
try {
// convert to (relative) URI and extract path. This will
// decode any %20 escapes in the name.
name = new URI(name).getPath();
} catch(URISyntaxException ex) {
// ignore, this should have been checked when adding the URL!
}
return name;
}
示例4: bucketCreate
import java.net.URISyntaxException; //導入依賴的package包/類
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("bucket/{bucketKey}")
public Response bucketCreate(
@Context HttpServletRequest request,
@PathParam("bucketKey") String bucketKey,
@QueryParam("policy") String policy,
@QueryParam("region") String region
)
throws IOException,
URISyntaxException
{
APIImpl impl = getAPIImpl( request );
if( impl == null )
{
return Response.status( Response.Status.UNAUTHORIZED ).build();
}
Result result = impl.bucketCreate( bucketKey, policy, region );
return formatReturn( result );
}
示例5: jButtonIniciarActionPerformed
import java.net.URISyntaxException; //導入依賴的package包/類
private void jButtonIniciarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIniciarActionPerformed
try {
// Consumiendo web service
String json = iniciarServidor();
user = new Gson().fromJson(json, Pc.class);
System.out.println("Recibido: " + user);
jLabel1.setForeground(Color.green);
Desktop.getDesktop().browse(new URI("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin"));
url.setText("http://" + ip + ":" + user.getPuertoPHP() + "/phpmyadmin");
jlabelSQL.setText("PuertoSQL: " + user.getPuertoSQL());
this.setTitle("App [ID:" + user.getId() + "]");
} catch (IOException | URISyntaxException ex) {
Logger.getLogger(VentanaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例6: doGet
import java.net.URISyntaxException; //導入依賴的package包/類
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response
) throws ServletException, IOException {
InputStreamReader in = new InputStreamReader(request.getInputStream());
PrintStream out = new PrintStream(response.getOutputStream());
calledTimes++;
try {
requestUri = new URI(null, null,
request.getRequestURI(), request.getQueryString(), null);
} catch (URISyntaxException e) {
}
in.close();
out.close();
}
示例7: getParentSources
import java.net.URISyntaxException; //導入依賴的package包/類
public File[] getParentSources() {
try
{
List<File> files=new ArrayList<File>();
for(URL url : mainClassLoader.getSources())
{
URI uri = url.toURI();
if(uri.getScheme().equals("file"))
{
files.add(new File(uri));
}
}
return files.toArray(new File[]{});
}
catch (URISyntaxException e)
{
FMLLog.log(Level.ERROR, e, "Unable to process our input to locate the minecraft code");
throw new LoaderException(e);
}
}
示例8: testGetBlob
import java.net.URISyntaxException; //導入依賴的package包/類
@Test
public void testGetBlob() throws URISyntaxException, IOException {
Path fileA = Paths.get(Resources.getResource("fileA").toURI());
String expectedFileAString = new String(Files.readAllBytes(fileA), StandardCharsets.UTF_8);
CachedLayer cachedLayer = new CachedLayer(fileA, mockBlobDescriptor, mockDiffId);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Blob fileBlob = cachedLayer.getBlob();
fileBlob.writeTo(outputStream);
Assert.assertEquals(
expectedFileAString, new String(outputStream.toByteArray(), StandardCharsets.UTF_8));
Assert.assertEquals(mockBlobDescriptor, cachedLayer.getBlobDescriptor());
Assert.assertEquals(mockDiffId, cachedLayer.getDiffId());
}
示例9: isLoadedFrom
import java.net.URISyntaxException; //導入依賴的package包/類
public static boolean isLoadedFrom(Class<?> clazz) {
if (clazz == null) {
throw new IllegalArgumentException("Need to provide valid class reference");
}
CodeSource codeSource = clazz.getProtectionDomain().getCodeSource();
if (codeSource != null) {
URL location = codeSource.getLocation();
if (isJarUrl(location)) {
try {
return findMarkerFileInJar(new File(location.toURI()));
} catch (URISyntaxException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
}
return false;
}
示例10: getMirrorInfo
import java.net.URISyntaxException; //導入依賴的package包/類
/**
* if the repository has a mirror, then create a repositoryinfo object for it..
*/
private RepositoryInfo getMirrorInfo(RepositoryInfo info, MirrorSelector selector, Settings settings) {
RemoteRepository original = new RemoteRepository.Builder(info.getId(), /* XXX do we even support any other layout?*/"default", info.getRepositoryUrl()).build();
RemoteRepository mirror = selector.getMirror(original);
if (mirror != null) {
try {
String name = mirror.getId();
//#213078 need to lookup name for mirror
for (Mirror m : settings.getMirrors()) {
if (m.getId() != null && m.getId().equals(mirror.getId())) {
name = m.getName();
break;
}
}
RepositoryInfo toret = new RepositoryInfo(mirror.getId(), name, null, mirror.getUrl());
toret.setMirrorStrategy(RepositoryInfo.MirrorStrategy.NONE);
return toret;
} catch (URISyntaxException ex) {
Exceptions.printStackTrace(ex);
}
}
return null;
}
示例11: getDistribution
import java.net.URISyntaxException; //導入依賴的package包/類
private static URL getDistribution (String distribution, URI base) {
URL retval = null;
if (distribution != null && distribution.length () > 0) {
try {
URI distributionURI = new URI (distribution);
if (! distributionURI.isAbsolute ()) {
if (base != null) {
distributionURI = base.resolve (distributionURI);
}
}
retval = distributionURI.toURL ();
} catch (MalformedURLException | URISyntaxException ex) {
ERR.log (Level.INFO, null, ex);
}
}
return retval;
}
示例12: sendBounceProbe
import java.net.URISyntaxException; //導入依賴的package包/類
/**
* Send a bounce probe to a user if they are bouncing
*
* @param groupId
* of the group they belong to
* @param subscriptionId
* of the subscription they have
* @return the user's {@link Subscription}
* @throws URISyntaxException
* @throws IOException
* @throws GroupsIOApiException
*/
public Subscription sendBounceProbe(final Integer groupId, final Integer subscriptionId)
throws URISyntaxException, IOException, GroupsIOApiException
{
if (apiClient.group().getPermissions(groupId).getManageMemberSubscriptionOptions()
&& getMemberInGroup(groupId, subscriptionId).getUserStatus().canSendBounceProbe())
{
final URIBuilder uri = new URIBuilder().setPath(baseUrl + "sendbounceprobe");
uri.setParameter("group_id", groupId.toString());
uri.setParameter("sub_id", subscriptionId.toString());
final HttpRequestBase request = new HttpGet();
request.setURI(uri.build());
return callApi(request, Subscription.class);
}
else
{
final Error error = new Error();
error.setType(GroupsIOApiExceptionType.INADEQUATE_PERMISSIONS);
throw new GroupsIOApiException(error);
}
}
示例13: getMainClass
import java.net.URISyntaxException; //導入依賴的package包/類
private static String getMainClass(VirtualMachineDescriptor vmd)
throws URISyntaxException, MonitorException {
try {
String mainClass = null;
VmIdentifier vmId = new VmIdentifier(vmd.id());
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
monitoredHost.detach(monitoredVm);
return mainClass;
} catch(NullPointerException e) {
// There is a potential race, where a running java app is being
// queried, unfortunately the java app has shutdown after this
// method is started but before getMonitoredVM is called.
// If this is the case, then the /tmp/hsperfdata_xxx/pid file
// will have disappeared and we will get a NullPointerException.
// Handle this gracefully....
return null;
}
}
示例14: setupEWS
import java.net.URISyntaxException; //導入依賴的package包/類
private void setupEWS() throws URISyntaxException {
URI uriForDecode = new URI(mAccount.getStoreUri());
//TODO: Different EWS auth types?
/*
* The user info we have been given from
* AccountSetupBasics.onManualSetup() is encoded as an IMAP store
* URI: AuthType:UserName:Password (no fields should be empty).
* However, AuthType is not applicable to EWS nor to its store
* URI. Re-encode without it, using just the UserName and Password.
*/
String userPass = "";
String[] userInfo = uriForDecode.getUserInfo().split(":");
if (userInfo.length > 1) {
userPass = userInfo[1];
}
if (userInfo.length > 2) {
userPass = userPass + ":" + userInfo[2];
}
String domainPart = EmailHelper.getDomainFromEmailAddress(mAccount.getEmail());
String suggestedServerName = serverNameSuggester.suggestServerName(EWS, domainPart);
URI uri = new URI("ews+ssl+", userPass, suggestedServerName, uriForDecode.getPort(),
"/"+ ExchangeVersion.Exchange2010_SP2.name()+"/EWS/Exchange.asmx", null, null);
mAccount.setStoreUri(uri.toString());
}
示例15: apiGetAuthorizerInfo
import java.net.URISyntaxException; //導入依賴的package包/類
/**
* 獲取公眾號基本信息。
*
* @param mpAppid
* @return
* @throws ClientProtocolException
* @throws URISyntaxException
* @throws IOException
* @throws AccessTokenFailException
*/
public GetAuthorizerInfo apiGetAuthorizerInfo(String mpAppid)
throws ClientProtocolException, URISyntaxException, IOException, AccessTokenFailException {
// 檢查MpAccessToken是否存在
AuthorizerAccessToken mpToken = runtime.getMpAuthorizerToken(mpAppid);
if (mpToken == null) {
throw new IllegalStateException("無法獲取公眾號基本信息,因為MpAccessToken不存在");
}
ComponentAccessToken caToken = apiComponentToken();
// 構建請求參數進行獲取
TreeMap<String, String> reqMsg = new TreeMap<String, String>();
reqMsg.put("component_appid", config.getComponentAppid());
reqMsg.put("authorizer_appid", mpAppid);
String path = String.format("/component/api_get_authorizer_info?component_access_token=%s",
caToken.getComponentAccessToken());
String respText = HttpUtil.post(config.getApiHttps(), path, reqMsg);
GetAuthorizerInfo resp = new Gson().fromJson(respText, GetAuthorizerInfo.class);
if (log.isInfoEnabled()) {
log.info(String.format("apiGetAuthorizerInfo %s", resp));
}
return resp;
}