import java.util.Scanner;
public class jdck {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入Cookie字符串:");
String cookie = scanner.nextLine();
String ptKey = extractValueFromCookie(cookie, "pt_key");
String ptPin = extractValueFromCookie(cookie, "pt_pin");
System.out.println("pt_key=" + ptKey+";"+"pt_pin="+ptPin+";");
}
private static String extractValueFromCookie(String cookie, String key) {
String value = null;
String keyWithEqualSign = key + "=";
int startIndex = cookie.indexOf(keyWithEqualSign);
if (startIndex != -1) {
startIndex += keyWithEqualSign.length();
int endIndex = cookie.indexOf(";", startIndex);
if (endIndex == -1) {
endIndex = cookie.length();
}
value = cookie.substring(startIndex, endIndex).trim();
}
return value;
}
}
版权属于:
星扬
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权
评论 (0)