A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

  1. package FilePakage;

  2. import java.io.*;
  3. import java.util.Enumeration;
  4. import java.util.Properties;
  5. import java.util.Vector;

  6. public class PropertiesDemo
  7. {
  8.         public static void main(String[] args) throws IOException
  9.         {
  10.                 FileOutputStream fileo = new FileOutputStream("E://text.txt");
  11.                 Vector<Person> v = new Vector<Person>();                       
  12.                 v.add(new Person("苍井空1",21));
  13.                 v.add(new Person("苍井空2",22));
  14.                 v.add(new Person("苍井空3",23));
  15.                 byte[] buf = new byte[1024];
  16.                 int len = 0;
  17.                
  18.                 fileo.close();
  19.         }
  20. }
  21. class Person
  22. {
  23.         private String name;
  24.         private int age;
  25.         Person(String name,int age)
  26.         {
  27.                 this.name = name;
  28.                 this.age = age;
  29.         }
  30.         public String toString()
  31.         {
  32.                 return name+" "+age;
  33.         }
  34. }
复制代码
上面的例子我想要 通过泛型手动输入元素 然后再存储在 指定文件中
不知道怎么写了  知道的大神教下

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马