package javaapplication25;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class Emails extends WindowAdapter implements ActionListener
{
Frame f;
TextField t1,t2;
Button b; Label l1,l2;
String s1,s2;
String s3="f";
String s4="hello@gmail.com";
String s5,s6;
String s7="00";
String s8=",";
FileOutputStream fos;
File f1;
String path,name;
int count=0;
public Emails()
{
f=new Frame();
f.setSize(400,400);
f.setLayout(new GridBagLayout());
b=new Button("Create");
b.addActionListener(this);
l1=new Label("Year");
l2=new Label("No Of Emails");
t1=new TextField();
t2=new TextField();
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridx=0;gbc.gridy=0;
gbc.gridwidth=2;gbc.gridheight=2;
gbc.ipadx=4;gbc.ipady=6;
gbc.fill=GridBagConstraints.HORIZONTAL;
gbc.anchor=GridBagConstraints.NORTH;
gbc.weightx=1.0;gbc.weighty=1.0;
Insets i=new Insets(30,5,7,9);
f.add(l1,gbc);
gbc.gridx=2;
f.add(t1,gbc);
gbc.insets=i;
gbc.gridy=2;
gbc.gridx=0;
f.add(l2,gbc);
gbc.gridx=2;
f.add(t2,gbc);
Insets i2=new Insets(30,5,7,9);
gbc.insets=i2;
gbc.gridy=5;
gbc.gridx=2;
f.add(b,gbc);
f.addWindowListener(this);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
try
{
String str=e.getActionCommand();
if(str.equals("Create"))
{
BufferedWriter bw=null;
path="D:/";
name="email.txt";
s1=t1.getText();
s2=t2.getText();
int a=Integer.parseInt(s2);
f1=new File(path,name);
if(f1.exists())
f1.delete();
fos = new FileOutputStream(f1);
for(int i=0;i<a;i++)
{
count= count+1;
/*if(count>9)
{
String c1=count+"";
String s9="0";
s5=s3+s1+s9+c1+s4+s8;
byte c[] = s5.getBytes();
fos.write(c);
}*/
s6=count+"";
s5=s3+s1+s7+s6+s4+s8;
byte c[] = s5.getBytes();
fos.write(c);
}
}
}
catch(IOException ef)
{
}
}
public void windowClosing(WindowEvent e2)
{
Window w=e2.getWindow();
w.setVisible(false);
w.dispose();
System.exit(1);
}
public static void main(String[] args)
{
Emails e=new Emails();
}
}