//String name,int number,int count,String type,String provider 商品数据写入类
import java.io.*;
public class Inputsomething{
public static InputStreamReader inreader=new InputStreamReader(System.in);
public static BufferedReader breader=new BufferedReader(inreader);
public static String name()throws Exception
{
String name;
System.out.println();
System.out.println("********************************//欢迎进入夏欣商品管理//***********************");
System.out.println();
System.out.println();
System.out.print(" 1、输入商品名,回车结束:");
name=breader.readLine();
name=name.trim();
name+="\n";
System.out.println();
System.out.println();
return name=name.trim();
}
public static int count()throws Exception
{
String count;
System.out.print(" 2、输入商品价格,回车结束:");
count=breader.readLine();
count=count.trim();
System.out.println();
System.out.println();
return Integer.parseInt(count);
}
public static int number()throws Exception
{
String number;
System.out.print(" 3、输入商品编号,回车结束:");
number=breader.readLine();
number=number.trim();
System.out.println();
System.out.println();
return Integer.parseInt(number);
}
public static String type()throws Exception
{
String type;
System.out.print(" (友情提示:电子类、体育类、食品类等)");
System.out.println();
System.out.println();
System.out.print(" 4、输入商品类型,回车结束:");
type=breader.readLine();
type=type.trim();
System.out.println();
System.out.println();
return type=type.trim();
}
public static String provider()throws Exception
{
String provider;
System.out.print(" 5、输入商品供应商,回车结束:");
provider=breader.readLine();
provider=provider.trim();
System.out.println();
System.out.println();
return provider=provider.trim();
}
public static String display()throws Exception
{
String display;
display="数据库写入成功!";
return display=display.trim();
}
/*Inputsomething(String name,String count,String number,String type,String provider){
this.name=name;
this.count=count;
this.number=number;
this.type=type;
this.provider=provider;
}*/
public static void main(String[] args)throws Exception {
Inputsomething Input=null;
Writer writer = null;
try {
writer = new FileWriter("c:\\5.txt");
writer.write(Input.name());
writer.write(" ");
writer.write(Integer.toString(Input.count()));
writer.write(" ");
writer.write(Integer.toString(Input.number()));
writer.write(" ");
writer.write(Input.type());
writer.write(" ");
writer.write(Input.provider());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (writer!=null)
try {
writer.close();
System.out.println("*********************************//"+Input.display()+"//***************************");
System.out.println();
System.out.println("***************************//查看商品数据请运行shopReader.class//**********************");
} catch (IOException e) {
}
}
}
}