當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。