http://sy3.cietv.com:554/live.soooner.com/5  CCTV-1 综合频道
http://sy3.cietv.com:554/live.soooner.com/5  CCTV-1 综合频道

比如上面这里的一个文件,我只想让它变成这样的:FILE=http://sy3.cietv.com:554/live.soooner.com/5
TITLE=CCTV-1 综合频道
FILE=http://sy3.cietv.com:554/live.soooner.com/5
TITLE=CCTV-1 综合频道
。哪位高人做的到,还请指点一二啊。

解决方案 »

  1.   

    用split分应该就可以了吧 分空格 分两段
      

  2.   

    随便找一个支持正则的文本编辑器:
    (1)“^”替换为“FILE=”
    (2)“ (?=CCTV)”替换为“\r\nTITLE=”
      

  3.   


    public static void main(String[] args) throws Exception{
    FileOutputStream dstout = new FileOutputStream("d:/dst.txt");
    InputStream in = new FileInputStream("d:/src.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String line = "";
    while((line=br.readLine())!=null){
    System.out.println(line);
    String lines[] = line.split("\\s",2);
    dstout.write(("FILE="+lines[0]).getBytes());
    dstout.write("\r\n".getBytes());
    dstout.write(("TITLE="+lines[1]).getBytes());
    dstout.write("\r\n".getBytes());
    }
    in.close();
    br.close();
    dstout.close();
    }
      

  4.   

    public static void main(String[] args) {
    String str = "http://sy3.cietv.com:554/live.soooner.com/5 CCTV-1 综合频道"; String reg = "(^http://.*? )(.*)";
    Pattern p = Pattern.compile(reg);
    Matcher match = p.matcher(str);
    StringBuffer result = new StringBuffer();
    int fileIndex = 1;
    int titleIndex = 2;
    String fileUrl = null;
    while (match.find()) {
    fileUrl = match.group(fileIndex);
    fileUrl = fileUrl.substring(0, fileUrl.length() - 1);
    result.append("FILE=").append(fileUrl).append("\n");
    result.append("TITLE=").append(match.group(titleIndex))
    .append("\n");
    }
    System.out.println(result.toString());
    }