本文整理汇总了Java中org.apache.commons.codec.net.URLCodec.encode方法的典型用法代码示例。如果您正苦于以下问题:Java URLCodec.encode方法的具体用法?Java URLCodec.encode怎么用?Java URLCodec.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.net.URLCodec
的用法示例。
在下文中一共展示了URLCodec.encode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
//return fileNameNoExtension;
URLCodec codec = new URLCodec();
try {
String fileNameURLEncoded = codec.encode(fileNameNoExtension);
String searchTerm = "http://www.javlibrary.com/" + siteLanguageToScrape + "/vl_searchbyid.php?keyword=" + fileNameURLEncoded;
return searchTerm;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例2: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
String fileBaseName;
if (file.isFile())
fileBaseName = FilenameUtils.getBaseName(Movie.getUnstackedMovieName(file));
else
fileBaseName = file.getName();
String[] splitBySpace = fileBaseName.split(" ");
if (splitBySpace.length > 1) {
// check if last word in filename contains a year like (2012) or [2012]
// we want to remove this from our search because it freaks out the search on excalibur films and gives no results
if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();
}
}
URLCodec codec = new URLCodec();
try {
fileBaseName = codec.encode(fileBaseName);
} catch (EncoderException e) {
e.printStackTrace();
}
fileBaseName = "http://www.excaliburfilms.com/search/adultSearch.htm?searchString=" + fileBaseName + "&Case=ExcalMovies&Search=AdultDVDMovies&SearchFor=Title.x";
return fileBaseName;
}
示例3: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
URLCodec codec = new URLCodec();
try {
String fileNameURLEncoded = codec.encode(fileNameNoExtension);
String searchTerm = "http://www.javbus.com/" + getUrlLanguageToUse() + "/search/" + fileNameURLEncoded;
return searchTerm;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例4: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
URLCodec codec = new URLCodec();
try {
String movieName = getMovieNameFromFileWithYear(file);
String year = getYearFromFileWithYear(file);
String fileNameURLEncoded = codec.encode(movieName);
String includeAdultParameter = "";
if (includeAdult)
includeAdultParameter = "&include_adult=true";
if (year != null && year.length() == 4) {
return "http://api.themoviedb.org/3/search/movie?api_key=" + tmdbKey + includeAdultParameter + "&query=" + fileNameURLEncoded + "&year=" + year;
} else
return "http://api.themoviedb.org/3/search/movie?api_key=" + tmdbKey + includeAdultParameter + "&query=" + fileNameURLEncoded;
} catch (EncoderException e) {
e.printStackTrace();
}
return null;
}
示例5: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
//return fileNameNoExtension;
URLCodec codec = new URLCodec();
try {
String fileNameURLEncoded = codec.encode(fileNameNoExtension);
String searchTerm = "http://www.javdog.com/" + siteLanguageToScrape + "/search/" + fileNameURLEncoded;
return searchTerm;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例6: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
//return fileNameNoExtension;
URLCodec codec = new URLCodec();
try {
String fileNameURLEncoded = codec.encode(fileNameNoExtension);
String searchTerm = "http://www.javlibrary.com/" + siteLanguageToScrape + "/vl_searchbyid.php?keyword=" + fileNameURLEncoded;
return searchTerm;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例7: getQRCodeAsURL
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Return the qrcodebaseURL which helps in displaying the QRCODE on the
* registration page at runtime.
*
* @param otpAuthURL
* OTP Auth URL of a user
* @param height
* height of the QR code
* @param width
* width of the QR code
* @return QRCode base URL of a user
* @throws OTPManagerException
* if a failure occur while generating QRCODE as url
*/
public static String getQRCodeAsURL(String otpAuthURL, int height, int width) throws OTPManagerException {
if (otpAuthURL == null || otpAuthURL.isEmpty()) {
LOG.error("otpAuthURL cannot be null or empty");
throw new OTPManagerException("otpAuthURL cannot be null or empty");
}
if (height <= 0 || width <= 0) {
LOG.error("Height or Width cannot be negative or zero");
throw new OTPManagerException("Height or Width cannot be negative or zero");
}
// Check whether the OPTAuth URL is valid or not
validateOTPAuthURL(otpAuthURL);
String qrcodeAsURL;
String encodedURL;
URLCodec codec = new URLCodec();
try {
encodedURL = codec.encode(otpAuthURL);
} catch (EncoderException e) {
LOG.error("Error while encoding otpAuthURL " + e.getMessage(), e);
throw new OTPManagerException("Error while encoding otpAuthURL " + e.getMessage(), e);
}
qrcodeAsURL = Constants.QRCODE_BASE_URL + height + "x" + width + "&chl=" + encodedURL;
return qrcodeAsURL;
}
示例8: getRequestStringFromMap
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Generate the request parameter portion of the url based on the map of key value pairs passed in
*
* @param requestParameters the request parameters to use in the string
* @return a request parameter string starting with "?" with "&" separators, or blank if the mapped passed in is
* blank
*/
public static String getRequestStringFromMap(Map<String, String> requestParameters) {
String requestString = "";
if (requestParameters.isEmpty()) {
return requestString;
}
URLCodec urlCodec = new URLCodec(KRADConstants.DEFAULT_ENCODING);
for (String key : requestParameters.keySet()) {
String value = null;
try {
value = urlCodec.encode(requestParameters.get(key));
} catch (EncoderException e) {
throw new RuntimeException("Unable to encode parameter name or value: " + key + "=" + value, e);
}
if (StringUtils.isNotBlank(requestString)) {
requestString = requestString + "&";
}
requestString = requestString + key + "=" + value;
}
return "?" + requestString;
}
示例9: urlEncode
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
/**
* Encodes in a www-form-urlencoded format using the default charset
* @param str the {@link String} to be encoded
* @return the www-form-urlencoded {@link String}
* @throws EncoderException if the encoding could not be done
*/
public static CharSequence urlEncode(final CharSequence str) throws EncoderException {
if (str == null) return null;
URLCodec codec = new URLCodec();
String encodedStr = codec.encode(str.toString());
return encodedStr;
}
示例10: escape_url_with_apache_commons
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Test
public void escape_url_with_apache_commons () throws EncoderException {
URLCodec codec = new URLCodec();
String urlEscaped = codec.encode(URL_TO_ESCAPE);
assertEquals("http%3A%2F%2Fwww.leveluplunch.com%3Fsomevar%3Dabc123%26someothervar", urlEscaped);
}
示例11: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileBaseName;
if (file.isFile())
fileBaseName = FilenameUtils.getBaseName(Movie.getUnstackedMovieName(file));
else
fileBaseName = file.getName();
fileName = fileBaseName;
String[] splitBySpace = fileBaseName.split(" ");
if (splitBySpace.length > 1) {
//check if last word in filename contains a year like (2012) or [2012]
if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
yearFromFilename = splitBySpace[splitBySpace.length - 1].replaceAll("[\\(\\[\\)\\]]", "");
fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();
}
}
if (useSiteSearch) {
URLCodec codec = new URLCodec();
try {
fileBaseName = codec.encode(fileBaseName);
} catch (EncoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fileBaseName = "http://www.data18.com/search/?k=" + fileBaseName + "&t=2";
return fileBaseName;
}
return FilenameUtils.getBaseName(file.getName());
}
示例12: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileNameNoExtension = findIDTagFromFile(file, isFirstWordOfFileIsID());
//System.out.println("fileNameNoExtension in DMM: " + fileNameNoExtension);
URLCodec codec = new URLCodec();
try {
String fileNameURLEncoded = codec.encode(fileNameNoExtension);
//System.out.println("FileNameUrlencode = " + fileNameURLEncoded);
return "http://www.dmm.co.jp/search/=/searchstr=" + fileNameURLEncoded + "/";
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例13: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileBaseName;
if (file.isFile())
fileBaseName = FilenameUtils.getBaseName(file.getName());
else
fileBaseName = file.getName();
System.out.println("fileBaseName = " + fileBaseName);
fileName = fileBaseName;
/*String [] splitBySpace = fileBaseName.split(" ");
if(splitBySpace.length > 1)
{
//check if last word in filename contains a year like (2012) or [2012]
if(splitBySpace[splitBySpace.length-1].matches("[\\(\\[]\\d{4}[\\)\\]]"))
{
yearFromFilename = splitBySpace[splitBySpace.length-1].replaceAll("[\\(\\[\\)\\]]", "");
fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]","").trim();
}
}*/
if (useSiteSearch) {
URLCodec codec = new URLCodec();
try {
fileBaseName = codec.encode(fileBaseName);
} catch (EncoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fileBaseName = "http://www.data18.com/search/?k=" + fileBaseName + "&t=0";
return fileBaseName;
}
return FilenameUtils.getBaseName(file.getName());
}
示例14: createSearchString
import org.apache.commons.codec.net.URLCodec; //导入方法依赖的package包/类
@Override
public String createSearchString(File file) {
scrapedMovieFile = file;
String fileBaseName;
String yearFromFilename = "";
if (file.isFile())
fileBaseName = FilenameUtils.getBaseName(file.getName());
else
fileBaseName = file.getName();
fileBaseName = fileBaseName.replaceFirst("\\s?CD[1234]", "");
fileName = fileBaseName;
String[] splitBySpace = fileBaseName.split(" ");
if (splitBySpace.length > 1) {
//check if last word in filename contains a year like (2012) or [2012]
if (splitBySpace[splitBySpace.length - 1].matches("[\\(\\[]\\d{4}[\\)\\]]")) {
yearFromFilename = splitBySpace[splitBySpace.length - 1].replaceAll("[\\(\\[\\)\\]]", "");
fileBaseName = fileBaseName.replaceFirst("[\\(\\[]\\d{4}[\\)\\]]", "").trim();
}
}
if (useSiteSearch) {
URLCodec codec = new URLCodec();
try {
fileBaseName = codec.encode(fileBaseName);
} catch (EncoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fileBaseName = "http://www.iafd.com/results.asp?searchtype=comprehensive&searchstring=" + fileBaseName;
return fileBaseName;
}
return FilenameUtils.getBaseName(file.getName());
}