当前位置: 首页>>代码示例>>Java>>正文


Java URISyntaxException类代码示例

本文整理汇总了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;
  }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:18,代码来源:BaseResource.java

示例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);
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:21,代码来源:TestExecutionController.java

示例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;
    }
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:26,代码来源:MainFrame.java

示例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 );
   }
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:21,代码来源:ForgeRS.java

示例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);
    }
}
 
开发者ID:AmauryOrtega,项目名称:Sem-Update,代码行数:18,代码来源:VentanaPrincipal.java

示例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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestJobEndNotifier.java

示例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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:ModClassLoader.java

示例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());
}
 
开发者ID:GoogleCloudPlatform,项目名称:minikube-build-tools-for-java,代码行数:17,代码来源:CachedLayerTest.java

示例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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:GradleRuntimeShadedJarDetector.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:RepositoryPreferences.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AutoUpdateCatalogParser.java

示例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);
    }
}
 
开发者ID:lake54,项目名称:groupsio-api-java,代码行数:34,代码来源:MemberResource.java

示例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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JCmd.java

示例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());
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:AccountSetupAccountType.java

示例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;
}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:36,代码来源:OpenApi.java


注:本文中的java.net.URISyntaxException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。