split()切割?问号
// split()中引入了正则 所以切割 ? 需要先转义 public static void main(String[] args) { String url = "http://172.0.0.1/zhangsan.jpg?age=20"; String[] split = url.split("\\?"); System.out.println("split = " + split[0]);//split = http://172.0.0.1/zhangsan.jpg }

浙公网安备 33010602011771号