请哪位朋友给我写几个简单的例子
一. 把一个字符串中的大写字母变成相应的小写字母(我写了一天总出错,找不到原因想求完整版)
二. 有个字符串abc,def,kkl;d;abc,ddf,把其中同abc相同的字符串去掉,把分号用,号代替。
三. 实现文件的复制与合并本人希望哪位大哥大姐帮帮小第,我都冒汗了,我不会给分,我有200可全给你们,谢谢了

解决方案 »

  1.   

    请把第二条再说清楚一点!
    第一条写成
    public class xx { public static void main(String[] args) {
    String str =null;
    String str1=null;
    str="ABcDEFG";
    str1=str.toLowerCase();
    System.out.println(str1);

    }
    }
      

  2.   

    二.
    String a = "abc,def,kkl;d;abc,ddf,";

    String b = a.replace("abc", "").replace(',', '.');
    System.out.println(b);给分点管理就可以了
      

  3.   

    1.使用String.toLowerCase() 
    2.使用String.replace(char oldChar, char newChar) 
    3.使用java.io.*包中的类,java examples这本书就有例子完全满足你的需要,你用google搜吧。
      

  4.   

    文件拷贝:import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;/**
     * @author Administrator
     *
     */
    public class CopyFile
    {
    public void copy(String srcFile, String dstFile) throws FileNotFoundException, IOException
    {
    BufferedReader br = new BufferedReader(new FileReader(srcFile));

    StringBuffer sb = new StringBuffer();
    String str = br.readLine();

    while (str != null)
    {
    sb.append(str + "\n");
    str = br.readLine();
    }

    br.close();

    BufferedWriter bw = new BufferedWriter(new FileWriter(dstFile));

    bw.write(sb.toString());

    bw.close();
    }
    /**
     * @param args
     */
    public static void main(String[] args)
    {
    // TODO Auto-generated method stub
    CopyFile cf = new CopyFile();

    try{
    cf.copy("e:\\test.txt", "e:\\test1.txt");

    }catch (Exception e)
    {
    System.out.println(e.getMessage());
    }
    }}
    自己再改一下就可以用了,不会说不知怎么改吧?
      

  5.   

    1,
    toLowerCase
    public String toLowerCase()
    Converts all of the characters in this String to lower case using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault()). 
    Returns:
    the String, converted to lowercase.
    2
    replace
    public String replace(CharSequence target,
                          CharSequence replacement)
    Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab". Parameters:
    target - The sequence of char values to be replaced
    replacement - The replacement sequence of char values 
    Returns:
    The resulting string 自己多查一下文档就好了 !
      

  6.   

    说别的都不顶用,还是给分吧,实惠人办实惠事,但还是谢谢
    第二条就是字符替换,去掉第一个字符串中的abc,然后把“;”号用“,”号替代打出
      

  7.   

    1.str.toLowerCase();
    2.replace("abc", "").replace(',', '.');
    3.
    while (str != null)
    {
    sb.append(str + "\n");
    str = br.readLine();
    }

    br.close();

    BufferedWriter bw = new BufferedWriter(new FileWriter(dstFile));

    bw.write(sb.toString());

    bw.close();
    }
      

  8.   

    public static void main(String[] args) {
        String a = "aBcD";
        a = a.toLowerCase();//将字符串中的大写字符转换成小写
        System.out.println(a);
        
        String b = "abc,def,kkl;d;abc,ddf,";
        b = b.replaceAll("abc","").replaceAll(";",",");////把字符串b其中和abc相同的字符串去掉,把字符串中的分号替换成逗号
        System.out.println(b);
    }
    /**
       * 拷贝文件
       * @param toFile原文件
       * @param fronFile目标文件
       * @return 返回1表示拷贝成功,返回0则不成功
       */ 
      public int toFile(String toFile,String fronFile){    try {
          File fronF = new File(fronFile);
          DataInputStream dis = new DataInputStream(new FileInputStream(fronF));
          int read = dis.read();
          FileOutputStream fqs = new FileOutputStream(toFile);
          while (read != -1) {
            fqs.write(read);
            read = dis.read();
          }
          dis.close();
          fqs.close();
        }
        catch (Exception e) {
          System.out.println(e.toString());
          return 0;
        }
        return 1;
      }
      

  9.   

    to  lei198203(lei):
    "\n" -> "\r\n"
    而且你做得每次都会在后面多加一个 回车~
    并且 我觉得在.close()前先.flush()会更好一点~