Y
yeszhang
Unregistered / Unconfirmed
GUEST, unregistred user!
package com.yeszhang.Function;
/**
* Created by IntelliJ IDEA.
* User: yeszhang
* Date: 2003-12-29
* Time: 11:15:37
* To change this template use Options | File Templates.
*/
import java.util.StringTokenizer;
import java.io.*;
import java.util.*;
import java.lang.String;
public class partitionStr {
public static void main(String[] args)
{
int i,runtimes=0;
String str1="142134@dasfkasj $dafjasf @ @jfaskjf ";
StringTokenizer str2;
str2=new StringTokenizer(str1);
System.out.print("输入测试数据 ");
String line = readLine();
System.out.print("输入的测试数据为:");
System.out.println(line);
System.out.println("主被隔离字符串为:"+str1);
System.out.print("设置隔离字符:");
String partitionstr1=readLine();
System.out.print("分离字符总串数为:");
System.out.println(str2.countTokens());
runtimes=str2.countTokens();
//TODO:countTokens()返回的值是由什么决定的?
for (i=0;i<runtimes;i++)
{
System.out.print("隔离字符为:"+partitionstr1+"被隔离字符种第"+i+"串为:");
System.out.println(str2.nextToken(partitionstr1));
}
}
//把输入的字符返回
public static String readLine() {
final int MAX_LINE_LEN = 1024;
try {
int readCount;
byte[] line = new byte[MAX_LINE_LEN];
readCount = System.in.read(line);
return new String(line, 0, readCount);
}
catch(IOException ioexp)
{
System.out.println("there is a IOException occured,the detailinfo is ");
}
{ return null;
}
}
}
我如何知道隔离完了呢?
也就是说 for (i=0;i<runtimes;i++)中runtimers值我如何给定呢?
countTokens();不晓得返回什么,呵呵!
/**
* Created by IntelliJ IDEA.
* User: yeszhang
* Date: 2003-12-29
* Time: 11:15:37
* To change this template use Options | File Templates.
*/
import java.util.StringTokenizer;
import java.io.*;
import java.util.*;
import java.lang.String;
public class partitionStr {
public static void main(String[] args)
{
int i,runtimes=0;
String str1="142134@dasfkasj $dafjasf @ @jfaskjf ";
StringTokenizer str2;
str2=new StringTokenizer(str1);
System.out.print("输入测试数据 ");
String line = readLine();
System.out.print("输入的测试数据为:");
System.out.println(line);
System.out.println("主被隔离字符串为:"+str1);
System.out.print("设置隔离字符:");
String partitionstr1=readLine();
System.out.print("分离字符总串数为:");
System.out.println(str2.countTokens());
runtimes=str2.countTokens();
//TODO:countTokens()返回的值是由什么决定的?
for (i=0;i<runtimes;i++)
{
System.out.print("隔离字符为:"+partitionstr1+"被隔离字符种第"+i+"串为:");
System.out.println(str2.nextToken(partitionstr1));
}
}
//把输入的字符返回
public static String readLine() {
final int MAX_LINE_LEN = 1024;
try {
int readCount;
byte[] line = new byte[MAX_LINE_LEN];
readCount = System.in.read(line);
return new String(line, 0, readCount);
}
catch(IOException ioexp)
{
System.out.println("there is a IOException occured,the detailinfo is ");
}
{ return null;
}
}
}
我如何知道隔离完了呢?
也就是说 for (i=0;i<runtimes;i++)中runtimers值我如何给定呢?
countTokens();不晓得返回什么,呵呵!