大家帮我看看程序那儿错了
我想将c:\ttt.txt变成c:\\ttt.txt
帮我看看那而错了,本来想用split,但是编出来的程序老是有异常,改了一下还是不对.
package com.topfounder.eclipse;
import java.util.*;
import java.io.*;
public class JavaTest {
static String getFilePath(String s)
{
int j=0;
String filePath=null;
ArrayList array=new ArrayList();
StringTokenizer st=new StringTokenizer(s.trim(),"\\");
while(st.hasMoreTokens())
{
array.add(st.nextElement());
}
for(int index=0;index<array.size()-1;index++)
{
filePath=filePath+array.get(index)+"\\";
}
filePath=filePath+array.get(array.size()-1);
return filePath;
}
public static void main(String[] args)
{
String s=getFilePath("c:\ttt.txt");
System.out.println(s);
}
}