I have a text file that would supposedly look like this
I am Hakan. My email address is hakan@cs.uh.edu, and what is your name? Hi my name is Tarikul and my favorite email address is tarikul2000@uh.edu
im supposed to create a program that will locate the emails in the file store the username,domaian, subdomain and extension then rewrite them int another text file.
import java.io.* ;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.io.PrintWriter;
import java.io.FileOutputStream;
public class Try {
public static void main(String[] args) {
Email [] storage;// email is a class that was made to store the data
try {
Scanner input= new Scanner("inputemails.txt");
PrintWriter output= new PrintWriter("outputemails.txt");
}
catch (FileNotFoundException e) {
System.out.print("File not found");
System.exit(0);}
int i=0;
while(input.hasNextLine()){
if(input.contains("@"));
{
storage[i]=
}
}
}
}
this is what i have so far , its not much but how would i get it to find the email in the text file?
also i thought it be better if i added the actual instructions to my assignment, im not asking for anyone to do the entire progam jus how would i separate the data i need to find
- Connect to the external input file. The name of the input file will always be inputemails.txt, and therefore please don’t ask the file name in your program.
- Detect the email addresses in the file.
- If an email does not have a sub-domain, please create Email object for that email.
- If an email has a sub-domain, please create UniversityEmail object for that email.
- Please store all emails in the same (one single) array list.
- After you copy all emails from the file to the array list, please ask the user what type of emails to be included in the output file. If the user enters 0, please write the emails that do not have sub-domain in the array list. Please note that the output file must start with a number indicating the number of emails in the file. If the user enters a number between 1-7, please write all emails from the specific department in the output file. Please note that the output file must start with a number indicating the number of emails in the file. The user can enter only one integer number from 0 to 8
and the subdomains its is talking about are
1 art 2 chee 3 chem 4 coe 5 cs 6 egr 7 polsci