本文整理汇总了Java中com.akdeniz.googleplaycrawler.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于com.akdeniz.googleplaycrawler包,在下文中一共展示了Utils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProxyClient
import com.akdeniz.googleplaycrawler.Utils; //导入依赖的package包/类
/**
* create a proxy client
*
* @return either a client or null if none is configured
* @throws KeyManagementException
* @throws NumberFormatException
* if that port could not be parsed.
* @throws NoSuchAlgorithmException
*/
private static HttpClient createProxyClient(PlayProfile profile)
throws KeyManagementException, NoSuchAlgorithmException {
if (profile.getProxyAddress() == null) {
return null;
}
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
DefaultHttpClient client = new DefaultHttpClient(connManager);
client.getConnectionManager().getSchemeRegistry()
.register(Utils.getMockedScheme());
HttpHost proxy = new HttpHost(profile.getProxyAddress(),
profile.getProxyPort());
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (profile.getProxyUser() != null && profile.getProxyPassword() != null) {
client.getCredentialsProvider().setCredentials(
new AuthScope(proxy),
new UsernamePasswordCredentials(profile.getProxyUser(), profile
.getProxyPassword()));
}
return client;
}
示例2: getProxyClient
import com.akdeniz.googleplaycrawler.Utils; //导入依赖的package包/类
/**
* Get a proxy client, if it is configured.
*
* @return either a client or null
* @throws IOException
* if reading the config file fails
* @throws KeyManagementException
* @throws NumberFormatException
* if that port could not be parsed.
* @throws NoSuchAlgorithmException
*/
public HttpClient getProxyClient() throws IOException, KeyManagementException,
NoSuchAlgorithmException, NumberFormatException {
File cfgfile = new File(root, NETCFG);
if (cfgfile.exists()) {
Properties cfg = new Properties();
cfg.load(new FileInputStream(cfgfile));
String ph = cfg.getProperty(PROXYHOST, null);
String pp = cfg.getProperty(PROXYPORT, null);
String pu = cfg.getProperty(PROXYUSER, null);
String pw = cfg.getProperty(PROXYPASS, null);
if (ph == null || pp == null) {
return null;
}
PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
SchemeRegistryFactory.createDefault());
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(30);
DefaultHttpClient client = new DefaultHttpClient(connManager);
client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme());
HttpHost proxy = new HttpHost(ph, Integer.parseInt(pp));
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
if (pu != null && pw != null) {
client.getCredentialsProvider().setCredentials(new AuthScope(proxy),
new UsernamePasswordCredentials(pu, pw));
}
return client;
}
return null;
}