So I've been working on a programm to use postmark to send emails through a GUI. What my issue is it works and all, but I have a SubscribedList and an unsubbedList.
What I'm trying to achieve is to scan the subbed and unsubbed and then send a string of the emails containing the unsubbed removed from the subbed and send it to another variable. I've half achieved this by:
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);
The last couple of lines half does what I want, but the unsubbed have to be in a specific order to properly remove from the subbed string.
so I was thinking something like this? Instead the String would be read in from a file but basically do the same job...
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]);
}