FormFile formFile = buildBagForm.getFormFile(); if (formFile.getFileName() == null || formFile.getFileName().length() == 0) { ActionMessages actionMessages = new ActionMessages(); actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionError("bagBuild.noBagToSave")); saveMessages(request, actionMessages); return mapping.findForward("buildBag"); } else { BufferedReader reader = new BufferedReader(new InputStreamReader(formFile.getInputStream()));  StringBuffer buffer = new StringBuffer(); String thisLine; while ((thisLine = reader.readLine()) != null) { StringTokenizer st = new StringTokenizer(thisLine, " \t"); while (st.hasMoreTokens()) { String token = st.nextToken(); bag.add(token); } } }
    public ActionForward makeStringBag(ActionMapping mapping,                                       ActionForm form,                                       HttpServletRequest request,                                       HttpServletResponse response)        throws Exception {        HttpSession session = request.getSession();        Map savedBags = (Map) session.getAttribute(Constants.SAVED_BAGS);        BuildBagForm buildBagForm = (BuildBagForm) form;        InterMineBag bag = new InterMineBag();        String trimmedText = buildBagForm.getText().trim();        if (trimmedText.length() == 0) {        } else {            for (StringTokenizer st = new StringTokenizer(trimmedText, " \t");                 st.hasMoreTokens();) {                String token = st.nextToken();                bag.add(token);            }        }        String newBagName = "new_bag";        if (savedBags == null) {            savedBags = new LinkedHashMap();            session.setAttribute(Constants.SAVED_BAGS, savedBags);        }        BagHelper.saveBag(bag, newBagName, savedBags);        String forwardPath = mapping.findForward("bagDetails").getPath() + "?bagName=" + newBagName;        ActionMessages actionMessages = new ActionMessages();        actionMessages.add(ActionMessages.GLOBAL_MESSAGE,                           new ActionError("bagBuilder.saved", newBagName));        saveMessages(request, actionMessages);        return new ActionForward(forwardPath);    }