当前位置: 首页>>代码示例>>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;未经允许,请勿转载。