當前位置: 首頁>>代碼示例>>Java>>正文


Java MalformedURLException類代碼示例

本文整理匯總了Java中java.net.MalformedURLException的典型用法代碼示例。如果您正苦於以下問題:Java MalformedURLException類的具體用法?Java MalformedURLException怎麽用?Java MalformedURLException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MalformedURLException類屬於java.net包,在下文中一共展示了MalformedURLException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.net.MalformedURLException; //導入依賴的package包/類
public static void main(String[] args) throws MalformedURLException, SolrServerException {
		String zkHost = "localhost:2181";
		String defaultCollection = "collection1";
		CloudSolrServer solr = new CloudSolrServer(zkHost);
		solr.setDefaultCollection(defaultCollection);
        
/*		ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("q", "cat:electronics");
    	params.set("defType", "edismax");
    	params.set("start", "0");*/
		
		SolrQuery params = new SolrQuery();
		params.setQuery("*:*");
		params.setSort("score ",ORDER.desc);
		params.setStart(Integer.getInteger("0"));
		params.setRows(Integer.getInteger("100"));
		
    

		QueryResponse response = solr.query(params);
		SolrDocumentList results = response.getResults();
		for (int i = 0; i < results.size(); ++i) {
			System.out.println(results.get(i));
		}
	}
 
開發者ID:dimensoft,項目名稱:improved-journey,代碼行數:26,代碼來源:SolrCloudSolrJSearcher.java

示例2: getClassLoader

import java.net.MalformedURLException; //導入依賴的package包/類
public ClassLoader getClassLoader(Location location) {
    nullCheck(location);
    Iterable<? extends File> path = getLocation(location);
    if (path == null)
        return null;
    ListBuffer<URL> lb = new ListBuffer<URL>();
    for (File f: path) {
        try {
            lb.append(f.toURI().toURL());
        } catch (MalformedURLException e) {
            throw new AssertionError(e);
        }
    }

    return getClassLoader(lb.toArray(new URL[lb.size()]));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:JavacFileManager.java

示例3: buildUrlWithLocationQuery

import java.net.MalformedURLException; //導入依賴的package包/類
/**
 * Builds the URL used to talk to the weather server using a location. This location is based
 * on the query capabilities of the weather provider that we are using.
 *
 * @param locationQuery The location that will be queried for.
 * @return The URL to use to query the weather server.
 */
private static URL buildUrlWithLocationQuery(String locationQuery) {
    Uri weatherQueryUri = Uri.parse(FORECAST_BASE_URL).buildUpon()
            .appendQueryParameter(QUERY_PARAM, locationQuery)
            .appendQueryParameter(FORMAT_PARAM, format)
            .appendQueryParameter(UNITS_PARAM, units)
            .appendQueryParameter(DAYS_PARAM, Integer.toString(numDays))
            .build();

    try {
        URL weatherQueryUrl = new URL(weatherQueryUri.toString());
        Log.v(TAG, "URL: " + weatherQueryUrl);
        return weatherQueryUrl;
    } catch (MalformedURLException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:fjoglar,項目名稱:android-dev-challenge,代碼行數:25,代碼來源:NetworkUtils.java

示例4: customValidate

import java.net.MalformedURLException; //導入依賴的package包/類
@Override
protected void customValidate(SectionInfo info, PortletEditingBean portlet, Map<String, Object> errors)
{
	try
	{
		final URL u = new URL(url.getValue(info));
		try
		{
			u.openConnection().connect();
		}
		catch( Exception e )
		{
			errors.put(
				"url",
				resources.getString("editor.rss.error.url.notreachable",
					e.getClass().getName() + ' ' + e.getMessage()));
		}
	}
	catch( MalformedURLException mal )
	{
		errors.put("url", resources.getString("editor.rss.error.url.notvalid"));
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:24,代碼來源:IframePortletEditorSection.java

示例5: HttpsPost

import java.net.MalformedURLException; //導入依賴的package包/類
/**
 *
 * @param requestURL
 * @param entity
 * @throws MalformedURLException
 * @throws IOException
 */
public HttpsPost(String requestURL, MultipartEntity entity) throws MalformedURLException, IOException {
    String boundary = "e2a540ab4e6c5ed79c01157c255a2b5007e157d7";
    URL url = new URL(requestURL);
    connection = (HttpsURLConnection) url.openConnection();
    connection.setUseCaches(false);
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    connection.setDoInput(true);
    connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
    process(entity, connection);
}
 
開發者ID:B-V-R,項目名稱:VirusTotal-public-and-private-API-2.0-implementation-in-pure-Java,代碼行數:19,代碼來源:HttpsPost.java

示例6: query_timestamp

import java.net.MalformedURLException; //導入依賴的package包/類
/**
    * 用於防釣魚,調用接口query_timestamp來獲取時間戳的處理函數
    * 注意:遠程解析XML出錯,與服務器是否支持SSL等配置有關
    * @return 時間戳字符串
    * @throws IOException
    * @throws DocumentException
    * @throws MalformedURLException
    */
public static String query_timestamp(AlipayConfig config) throws MalformedURLException,
                                                       DocumentException, IOException {

       //構造訪問query_timestamp接口的URL串
       String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + config.getPartnerId() + "&_input_charset" +AlipayConfig.inputCharset;
       StringBuffer result = new StringBuffer();

       SAXReader reader = new SAXReader();
       Document doc = reader.read(new URL(strUrl).openStream());

       List<Node> nodeList = doc.selectNodes("//alipay/*");

       for (Node node : nodeList) {
           // 截取部分不需要解析的信息
           if (node.getName().equals("is_success") && node.getText().equals("T")) {
               // 判斷是否有成功標示
               List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
               for (Node node1 : nodeList1) {
                   result.append(node1.getText());
               }
           }
       }

       return result.toString();
   }
 
開發者ID:superkoh,項目名稱:k-framework,代碼行數:34,代碼來源:AlipaySubmit.java

示例7: listOrganisations

import java.net.MalformedURLException; //導入依賴的package包/類
@Restrict({@Group("STUDENT")})
public CompletionStage<Result> listOrganisations() throws MalformedURLException {
    URL url = parseUrl();
    WSRequest request = wsClient.url(url.toString());
    String localRef = ConfigFactory.load().getString("sitnet.integration.iop.organisationRef");

    Function<WSResponse, Result>  onSuccess = response -> {
        JsonNode root = response.asJson();
        if (response.getStatus() != 200) {
            return internalServerError(root.get("message").asText("Connection refused"));
        }
        if (root instanceof ArrayNode) {
            ArrayNode node = (ArrayNode) root;
            for (JsonNode n : node) {
                ((ObjectNode) n).put("homeOrg", n.get("_id").asText().equals(localRef));
            }
        }
        return ok(root);
    };
    return request.get().thenApplyAsync(onSuccess);
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:22,代碼來源:OrganisationController.java

示例8: testGetSessionForFirstTime

import java.net.MalformedURLException; //導入依賴的package包/類
public void testGetSessionForFirstTime() throws MalformedURLException {
    WebRequest wr = new GetMethodWebRequest( "http://localhost/simple" );
    ServletUnitContext context = new ServletUnitContext();
    assertEquals( "Initial number of sessions in context", 0, context.getSessionIDs().size() );

    ServletUnitHttpRequest request = new ServletUnitHttpRequest( NULL_SERVLET_REQUEST, wr, context, new Hashtable(), NO_MESSAGE_BODY );
    assertNull( "New request should not have a request session ID", request.getRequestedSessionId() );
    assertNull( "New request should not have a session", request.getSession( /* create */ false ) );
    assertEquals( "Number of sessions in the context after request.getSession(false)", 0, context.getSessionIDs().size() );

    HttpSession session = request.getSession();
    assertNotNull( "No session created", session );
    assertTrue( "Session not marked as new", session.isNew() );
    assertEquals( "Number of sessions in context after request.getSession()", 1, context.getSessionIDs().size() );
    assertSame( "Session with ID", session, context.getSession( session.getId() ) );
    assertNull( "New request should still not have a request session ID", request.getRequestedSessionId() );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:18,代碼來源:HttpServletRequestTest.java

示例9: getTemplateGroupFile

import java.net.MalformedURLException; //導入依賴的package包/類
private static STGroupFile getTemplateGroupFile(String templatePath) throws MalformedURLException {

        if (templatePath == null) {
             return null;
        }

        if (!templatePath.contains(".jar!")) {
            return new STGroupFile(templatePath);
        }

        String protocol = "jar:";
        if (templatePath.startsWith(protocol)) {
            protocol = "";
        }

        URL url = new URL(protocol + templatePath);
        return  new STGroupFile(url, "US-ASCII", '%', '%');
    }
 
開發者ID:mattkol,項目名稱:SugarOnRest,代碼行數:19,代碼來源:Generators.java

示例10: addServerInClasspath

import java.net.MalformedURLException; //導入依賴的package包/類
private String[] addServerInClasspath(String[] args) {
    return Arrays.stream(args).filter(arg -> {
        if(arg.startsWith("--serverJar=")) {
            String serverURL = arg.substring("--serverJar=".length());
            File serverFile = new File(serverURL);

            if(!serverFile.exists())
                throw new IllegalArgumentException("Cannot found server jar.");

            try {
                this.classLoader.addURL(serverFile.toURI().toURL());
            } catch(MalformedURLException exc) {
                exc.printStackTrace();
            }
            return false;
        } else {
            return true;
        }
    }).toArray(String[]::new);
}
 
開發者ID:Gogume1er,項目名稱:caoutchouc,代碼行數:21,代碼來源:Caoutchouc.java

示例11: storeConfigValues

import java.net.MalformedURLException; //導入依賴的package包/類
@Override
protected void storeConfigValues() {
    RepositoryConnection rc = repository.getSelectedRCIntern();
    if(rc == null) {
        return; // uups
    }

    try {
        SVNUrl repositoryUrl = rc.getSvnUrl();
        if(repositoryUrl.getProtocol().startsWith("svn+")) {
            SvnConfigFiles.getInstance().setExternalCommand(SvnUtils.getTunnelName(repositoryUrl.getProtocol()), panel.tunnelCommandTextField.getText());
        }
    } catch (MalformedURLException mue) {
        // should not happen
        Subversion.LOG.log(Level.INFO, null, mue);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ConnectionType.java

示例12: getUrlFromFilesystem

import java.net.MalformedURLException; //導入依賴的package包/類
/** Search for the input resource in the filesystem */
private static URL getUrlFromFilesystem(String resourceName) {
    URL url = null;
    File f = new File(resourceName);
    try {
        if (f.exists() && f.isFile()) {
            // The following works in Java1.6
            //// The following does not work if the filename contains space-characters and if we do a url.openStream() on it.
            ////url = f.toURI().toURL();
            //url = f.toURL();
            url = f.toURI().toURL();
        }
    } catch (MalformedURLException e) {
        // do nothing
        url = null;
    }
    return url;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:19,代碼來源:URLHelper.java

示例13: browseIcon

import java.net.MalformedURLException; //導入依賴的package包/類
private URL browseIcon( ImagePreview preview ) {
    URL res = null;
    JFileChooser chooser = UIUtil.getIconFileChooser();
    int ret = chooser.showDialog(this, NbBundle.getMessage(getClass(), "LBL_Select")); // NOI18N
    if (ret == JFileChooser.APPROVE_OPTION) {
        File file =  chooser.getSelectedFile();
        try {
            res = Utilities.toURI(file).toURL();
            preview.setImage(new ImageIcon(res));
            setModified();
        } catch (MalformedURLException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:BasicBrandingPanel.java

示例14: getMarkets

import java.net.MalformedURLException; //導入依賴的package包/類
/**
 *
 * @param locale
 * @return
 * @throws MalformedURLException
 * @throws IOException
 * @throws JSONException
 */
public JSONObject getMarkets(String locale) throws MalformedURLException,
		IOException, JSONException {
	ArrayList<String> crumbs = new ArrayList<String>();
	crumbs.add("reference");
	crumbs.add(version);
	crumbs.add("countries");
	crumbs.add(locale);

	HashMap<String, String> parameters = new HashMap<String, String>();
	parameters.put("apiKey", apiKey);

	HashMap<String, String> properties = new HashMap<String, String>();
	properties.put("charset", "utf-8");
	properties.put("Accept", "application/json");

	request.buildUrl(baseUrl, crumbs, parameters);
	request.connect(properties);
	parsed = new JSONObject(request.get());

	return parsed;
}
 
開發者ID:mbp76,項目名稱:skyscanner-business-client-java,代碼行數:30,代碼來源:TravelCommon.java

示例15: getRegisterNr

import java.net.MalformedURLException; //導入依賴的package包/類
public ArrayList getRegisterNr() throws MalformedURLException, IOException {
    TextFormatter tf = new TextFormatter();
    URLConnection connection = new URL("http://pmg.ages.at/pls/psmlfrz/pmgweb2$.Startup").openConnection();
    ArrayList<Integer> numbers;
    try (Scanner regis = new Scanner(connection.getInputStream())) {
        regis.useDelimiter("\\Z");
        String helpi = searchDeli;
        searchDeli = "Registernummer:";
        String numbersText = tf.htmlToText(getRegValues(regis));
        String[] numbersField = numbersText.split("#");
        numbers = new ArrayList<>();
        for (String number : numbersField) {
            numbers.add(Integer.parseInt(number));
        }   searchDeli = helpi;
    }
    return numbers;
}
 
開發者ID:froehlichA,項目名稱:RA-Reader,代碼行數:18,代碼來源:Pagescrap.java


注:本文中的java.net.MalformedURLException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。