sorry, 问题2应该是:
if (!isExist(szFileName))
{
  create(szFileName);
}
else
{
  do nothing;
}

解决方案 »

  1.   

    1 这个我不是太清楚~好像如果是NT/2000/XP可以直接去控制面板的系统的高级选项里查看2 File name=new File(szFileName);
    if(name.exists())
       return;
    else
       File fileName=new File(name);
          try
          {      FileWriter output=new FileWriter(name);
          }
          catch(IOException ioException)
          {
                    JOptionPane.showMessageDialog(this,
                      "Error Open file","Error",
                      JOptionPane.ERROR_MESSAGE);
                    System.exit(1);
          }
      

  2.   

    StringTokenizer st;
    String s4 = ("a,b,c,d,e,")
    st = new StringTokenizer(s4, ",");
    while(st.hasMoreTokens()){
      out.print(st.nextToken();
    }
      

  3.   

    3
    JTextArea outputArea;
    File name=new File(szFileName);
    BufferedReader input=new BufferedReader(new FileReader(name));
    StringBuffer buffer=new StringBuffer();
    String text;
    while((text=input.readLine())!=null)
        buffer.append(text+"\n");
    outputArea.append(buffer.toString());
    4String strings=new String("abc,ddfasd,adsdf,dsadf,adfsdf,sdfsdf");
    StringTokenizer tokens=new StringTokenizer(strings,",");
    int i=tokens.countTokens();
    String array=new String[i];
    int j=0;
    while(tokens.hasMoreTokens())
    {
      array[j]=(String)tokens.nextToken());
      j++;
    }菜鸟的问题菜鸟解决^_^
     
      

  4.   

    4.如何将如下的逗号分隔的string分裂(split)到string数组中
    abc,ddfasd,adsdf,dsadf,adfsdf,sdfsdf
    --------------------------import java.util.*;class StringDivide {    public StringDivide(String string,String delimiters) {
    this.string = string;
    this.delimiters = delimiters;
    } public static void main(String[] args) {
    StringDivide s = new StringDivide("abc,ddfasd,adsdf,dsadf,adfsdf,sdfsdf",",");
    StringTokenizer st = new StringTokenizer(s.string,s.delimiters);
    while(st.hasMoreTokens()) {
    System.out.println(st.nextToken());
    }
    } private String string;
    private String delimiters;
    }
      

  5.   

    在WinNT,2000,XP里,就在系统属性--〉高级--〉环境变量里面看同时,在Windows系统都可以这样子看,进入命令行,打set命令如果要知道具体的某个变量的设置,输入:set 变量名,如:set path如果要设置变量名,输入:set 变量名=值  如,set classpath=.;当前目录
      

  6.   

    4.如何将如下的逗号分隔的string分裂(split)到string数组中
    abc,ddfasd,adsdf,dsadf,adfsdf,sdfsdf
    =>
    String 中的一个split函数
    String a = "a,b,c,d,e";
    String[] b = a.split(",");
      

  7.   

    其他的几个别人都贴了,我就贴环境变量吧。
    环境变量是系统相关的,在2000/xp下面要执行cmd.exe /c set 再win98下面要执行command.com /c set,再unix下面要执行env命令才能得到所有环境变量
    下面是代码:
    public static Properties getEnvVars() {
    Process p = null;
    Properties envVars = new Properties();
    try {
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
    // System.out.println(OS);
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set" );
    }
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1
    || (OS.indexOf("windows xp") > -1) ) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set" );
    }
    else {
    // our last hope, we assume Unix (thanks to H. Ware for the fix)
    p = r.exec( "env" );
    }
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String line;
    while( (line = br.readLine()) != null ) {
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    envVars.setProperty( key, value );
    System.out.println( key + " = " + value );
    }
    }
    catch (Exception e) {
    e.printStackTrace();
    // we do not care here. Just no env vars for the user. Sorry.
    }
    return envVars;
    }
      

  8.   

    借个地方问个问题
    path和classpath有什么区别??^_^
      

  9.   

    先感谢各位的大力相助.
    关于问题1, 其实我只是想得到某个已知名字的环境变量的值, java中应该有某个class的某个方法有和c语言中的getenv()函数功能相同吧? 还是非常感谢CoolAbu的精彩回答,让我知道如何得到系统所有环境变量的值. 其他的回答我也很满意.
    有谁知道java中的getenv()吗? 有答案我就马上加分结贴啦.:)
      

  10.   

    System.getenv()这个方法已不再支持,也是得到环境变量的
      

  11.   

    这里有部分方法,但估计不是你想要的,你把上面那个方法封装一下也行呀。System.out.println(System.getProperty("java.version"));
    System.out.println(System.getProperty("java.home"));
    System.out.println(System.getProperty("java.class.version"));
    System.out.println(System.getProperty("java.class.path"));
    System.out.println(System.getProperty("java.io.tmpdir"));
    System.out.println(System.getProperty("java.compiler"));
    System.out.println(System.getProperty("java.ext.dirs"));
    System.out.println(System.getProperty("os.name"));
    System.out.println(System.getProperty("os.arch"));
    System.out.println(System.getProperty("os.version"));
    System.out.println(System.getProperty("file.separator"));
    System.out.println(System.getProperty("path.separator"));
    System.out.println(System.getProperty("line.separator"));
    System.out.println(System.getProperty("user.name"));
    System.out.println(System.getProperty("user.home"));
    System.out.println(System.getProperty("user.dir"));