package review1;
import java.util.Scanner;
public class Str1 {
public static void main(String[] args) {
String words= "长亭外,古道边,芳草碧连天。晚风拂柳笛声残,夕阳山外山。\r\n" +
"天之涯,地之角,知交半零落。一瓢浊酒尽余欢,今宵别梦寒。 ";
String arr[]=new String[200];
System.out.println("原格式:"+words);
arr=words.split(",");
System.out.println("拆分后:");
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
do {
a();
} while (true);
}
public static void a() {
boolean fileCorrect=false;
boolean emailCorrecy=false;
System.out.println("欢迎进入文件系统");
Scanner input=new Scanner(System.in);
System.out.println("请输入文件名:");
String name=input.next();
System.out.println("请输入你的邮箱:");
String email=input.next();
int index=name.lastIndexOf('.');
if (index!=-1&name.subSequence(index+1, name.length()).equals("docx")) {
fileCorrect=true;
} else {
System.out.println("文件名无效");
}
if (email.indexOf('@')!=-1&email.indexOf('.')>email.indexOf('@')) {
emailCorrecy=true;
} else {
System.out.println("email格式错误");
}
if (fileCorrect&emailCorrecy) {
System.out.println("提交作业成功!");
} else {
System.out.println("提交作业失败!");
}
}
}
原格式:长亭外,古道边,芳草碧连天。晚风拂柳笛声残,夕阳山外山。
天之涯,地之角,知交半零落。一瓢浊酒尽余欢,今宵别梦寒。
拆分后:
长亭外
古道边
芳草碧连天。晚风拂柳笛声残
夕阳山外山。
天之涯
地之角
知交半零落。一瓢浊酒尽余欢
今宵别梦寒。
欢迎进入文件系统
请输入文件名:
。docx
请输入你的邮箱:
@.
文件名无效
提交作业失败!
欢迎进入文件系统
请输入文件名:
.docx
请输入你的邮箱:
@.
提交作业成功!
欢迎进入文件系统
请输入文件名: