本文整理汇总了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));
}
}
示例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()]));
}
示例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;
}
}
示例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"));
}
}
示例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();
}
示例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);
}
示例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() );
}
示例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", '%', '%');
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}