try{
String str;
str=jTextField2.getText();
File file=new File("info.txt");
PrinteWriter out=new PrinteWriter(new FileWriter(file)));
out.println(str);
out.close();
}catch(Exception e){e.printStackTrace();}
String str;
str=jTextField2.getText();
File file=new File("info.txt");
PrinteWriter out=new PrinteWriter(new FileWriter(file)));
out.println(str);
out.close();
}catch(Exception e){e.printStackTrace();}
{
String str;
str="用户名: "+jTextField2.getText();
File file=new File("info.txt");
PrintWriter out=new PrintWriter(new FileWriter(file,true));
out.print(str);
out.close();
}
catch(IOException e)
{
e.getMessage();
}
import java.io.*;class Try
{
public static void main(String[] args)
{
JTextField jTextField2=new JTextField();
JFrame f = new JFrame("dd");
f.getContentPane().add(jTextField2);
f.setSize(100,100);
f.show();
try
{
String str;
Thread.sleep(3000);
str="用户名: "+jTextField2.getText();
File file=new File("info.txt"); PrintWriter out=new PrintWriter(new FileWriter(file,true));
out.print(str);
out.close();
System.exit(0);
}
catch(Exception e)
{
e.printStackTrace();
} }
}