java字符串使用问题
我现在有一个字符串,保存了文件路径例如:c:\config\config.xml
我如何分别取得文件名‘config.xml’和路径名'c:\config\'
这样
Java code:
public static void main(String[] args) throws Exception {
String s = "c:/config/config.xml";
Matcher m = Pattern.compile(".*/").matcher(s);
while (m.find()) {
System.out.println(m.group());
System.out.println(s.substring(m.end(), s.length()));
}
}
或者
Java code:
public static void main(String[] args) throws Exception {
String s = "c:/config/config.xml";
Matcher m = Pattern.compile("(.*)/(.*)").matcher(s);
while (m.find()) {
System.out.println(m.group(1));
System.out.println(m.group(2));
}
}
Java code:
public static void main(String[] args) {
String str = "c:\\config\\config.xml";
String str1 = "",str2="";
str1 = str.substring(0, str.lastIndexOf("\\")+1);
Syst
相关问答:
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......
我想做够购物车用session 但是不知道怎么获取购买数量 谁有具体的代码吗 希望能割舍
下面是购物车的核心代码
有了这个 就应该能够做出来吧
Java code:
public void doPost(HttpServletRequest reque ......
字符流的读和写最终在底层都是通过字节流来完成的吗? 读写文本文件字符流应该就可以了吧。。
各位大哥大姐帮帮忙阿
Java流包括字节流和字符流,字节流通过IO设备以字节数据的方式读入,而字符流则是通过字节流 ......
我想用Java写一个程序,就是我想在运行代码后,在指定的时间打开某程序,例如我运行代码后,讲在12:00打开"D:\Program Files\Tencent\QQ2009\Bin\QQ.exe"这个程序,求高人指点。还有可能的话在指定的时间 ......
当知道一个日期,如何把这个日期所在旬的前后两个日期取出
比如输入20090905,就输入20090901 20090910
输出20090901 20090910
取得天数后作一下判断再把这个方法用下void set(int field, int value)
......