int 与String之间的互相转换

int 转String:常用Integer.parseInt()方法和Integer.valueOf()方法
其他整型转String型也都是像以上一样,整型对应包装类采用方法;

public static void Sales() throws IOException {
		ArrayListlist=new ArrayList();
		ArrayListlis=new ArrayList();
		OutputStreamWriter writer=new OutputStreamWriter(new FileOutputStream(new File("./bookStore.txt")));
		InputStreamReader sr=new InputStreamReader(new FileInputStream(new File("./bookStore.txt")));
		BufferedReader br=new BufferedReader(sr);
		OutputStreamWriter writer1=new OutputStreamWriter(new FileOutputStream(new File("./sell.txt")));
		InputStreamReader sr1=new InputStreamReader(new FileInputStream(new File("./sell.txt")));
		BufferedReader br1=new BufferedReader(sr1);
		ObjectOutputStream oos1=new ObjectOutputStream(new FileOutputStream(new File("./sell.txt")));
		String line=null;
		String line1=null;
		//将书库内容按行加入集合
		while ((line=br.readLine()) != null) {
			if("exit".equals(line)){				
				System.exit(1);				
			} 
			list.add(line);
			
		}
		br.close();
		sr.close();
		//将销售记录按行加入另一个集合
		while ((line1=br1.readLine()) != null) {
			if("exit".equals(line1)){				
				System.exit(1);				
			} 
			lis.add(line1);
			
		}
		br1.close();
		sr1.close();
		SellBook sb=new SellBook();
		@SuppressWarnings("resource")
		Scanner input=new Scanner(System.in);
		System.out.println("请输入卖出的图书名称:");
		sb.setName(input.next());
		System.out.println("请输入卖出的图书数量:");
		sb.setNumber(input.nextInt());
		int temp=0;//用于判断书库是否存在该图书
		int temp1=0;//用于判断书库图书是否足量
		
		for (int i = 0; i < list.size(); i++) {
			String[]list1=list.get(i).split(",");
			if (sb.getName().equals(list1[1])) {
				sb.setAuther(list1[2]);
				**sb.setIprice(Float.parseFloat(list1[3]));
				sb.setSprice(Float.parseFloat(list1[4]));**
				sb.setNum(lis.size()+1);
				
				temp++;
				//修改书库该图书的记录
				if (sb.getNumber()

String转int:常用String.valueOf()方法;
其他整型类似;

你可能感兴趣的:(个人理解)