所以我一直在开发一个程序来使用邮戳通过 GUI 发送电子邮件。我的问题是它有效,但我有一个订阅列表和一个未订阅列表。
我想要实现的是扫描 subbed 和 unsubbed,然后发送包含从 subbed 中删除的 unsubbed 的电子邮件字符串,并将其发送到另一个变量。我通过以下方式实现了一半:
public static void getEmail() throws Exception{
File Emailpath = new File(EmailListPath);
File Unsubpath = new File("c:\\test\\PostMark\\unsubbedEmailList.txt");
FileInputStream fis = new FileInputStream(Emailpath);
InputStreamReader isr = new InputStreamReader(fis);
FileInputStream unsubInput = new FileInputStream(Unsubpath);
InputStreamReader unsubisr = new InputStreamReader(unsubInput);
Scanner readEmail = new Scanner(Emailpath);
Scanner readUnsub = new Scanner(Unsubpath);
int i = 0;
System.err.println("Subbed List: ");
while (readEmail.hasNext()) {
//i++;
String line = readEmail.nextLine();
System.err.println(line);
EmailAddress = EmailAddress+","+line;
}
System.err.println("\nUnsubbed List: ");
while (readUnsub.hasNext()) {
//i++;
String line = readUnsub.nextLine();
System.err.println(line);
unsubbedEmailAddress = unsubbedEmailAddress+","+line;
}
//System.err.println("\n"+EmailAddress);
unsubbedEmailAddress=unsubbedEmailAddress.substring(1, unsubbedEmailAddress.length());
EmailAddress=EmailAddress.substring(1, EmailAddress.length());
EmailAddress = EmailAddress.replaceAll(unsubbedEmailAddress,"");
System.err.println("Subbed:\n"+EmailAddress);
System.err.println("Unsubbed:\n"+unsubbedEmailAddress);
System.err.println("\nSending to:\n"+EmailAddress);
最后几行的一半是我想要的,但是未加字幕的必须按照特定的顺序才能从已加字幕的字符串中正确删除。
所以我在想这样的事情?相反,字符串将从文件中读取,但基本上做同样的工作......
String subbed = "aaronjoyce2@gmail.com,aaronjoyce09@gmail.com,aaronscallyjoyce@gmail.com",
unsubbed = "aaronjoyce09@gmail.com";
String[] subbedArray, unsubbedArray, sendArray = null;
subbedArray = subbed.split(",");
for(int i = 0;i<=subbedArray.length -1;i++){
//System.err.println("Subbed:");
System.out.println(subbedArray[i]);
}
System.err.println("\n");
unsubbedArray=unsubbed.split(",");
for(int i = 0;i<=unsubbedArray.length-1;i++){
System.out.println(unsubbedArray[i]);
}
System.err.println("\n");
for(int i = 0;i<=unsubbedArray.length-1;i++){
int j=0;
if(subbedArray[i].equals(unsubbedArray[j]))
sendArray[i]= unsubbedArray[i];
else
for(j = 0;j<=unsubbedArray.length-1;j++){
if(subbedArray[i].equals(unsubbedArray[j]))
sendArray[i]= unsubbedArray[i];
}
System.out.println(sendArray[i]);
}