Example usage for java.util Scanner hasNextLine

List of usage examples for java.util Scanner hasNextLine

Introduction

In this page you can find the example usage for java.util Scanner hasNextLine.

Prototype

public boolean hasNextLine() 

Source Link

Document

Returns true if there is another line in the input of this scanner.

Usage

From source file:cz.cuni.amis.planning4j.validation.external.ValValidator.java

@Override
public IValidationResult validate(IPDDLFileDomainProvider domainProvider,
        IPDDLFileProblemProvider problemProvider, List<ActionDescription> plan) {
    File mainExecutable = new File(validatorDirectory,
            getValidatorFolderName() + File.separatorChar + getValidatorExecutableName());
    if (!mainExecutable.exists()) {
        String toolMessage = "Could not find validator executable '" + getValidatorExecutableName()
                + "' in directory " + validatorDirectory.getAbsolutePath();
        throw new ValidationException(toolMessage);
    }/*w  ww  .j a  v  a 2  s .  co  m*/
    FileWriter planWriter = null;
    Process process = null;
    try {

        /**
         * Write the plan to a temp file
         */
        File planTempFile = File.createTempFile("plan", ".soln");
        planWriter = new FileWriter(planTempFile);
        for (ActionDescription action : plan) {
            planWriter.write(action.getStartTime() + ": (" + action.getName() + " ");
            for (String param : action.getParameters()) {
                planWriter.write(param + " ");
            }
            planWriter.write(") [" + action.getDuration() + "]\n");
        }

        planWriter.close();
        planWriter = null;
        /**
         * Invoke the validator
         */
        ProcessBuilder processBuilder = new ProcessBuilder(mainExecutable.getAbsolutePath(), "-s", //silent mode for simple parsing - only errors are printed to the stdout
                domainProvider.getDomainFile().getAbsolutePath(),
                problemProvider.getProblemFile().getAbsolutePath(), planTempFile.getAbsolutePath());

        logger.info("Starting VAL validator.");
        if (logger.isDebugEnabled()) {
            logger.debug("The command: " + processBuilder.command());
        }
        process = processBuilder.start();

        Scanner outputScanner = new Scanner(process.getInputStream());

        StringBuilder consoleOutputBuilder = new StringBuilder();

        boolean hasNonEmptyLines = false;
        if (logger.isTraceEnabled()) {
            logger.trace("Validator output:");
        }
        while (outputScanner.hasNextLine()) {
            String line = outputScanner.nextLine();
            if (!consoleOutputBuilder.toString().isEmpty()) {
                consoleOutputBuilder.append("\n");
            }
            if (!line.trim().isEmpty()) {
                hasNonEmptyLines = true;
            }
            consoleOutputBuilder.append(line);
            if (logger.isTraceEnabled()) {
                logger.trace(line);
            }
        }
        if (logger.isTraceEnabled()) {
            logger.trace("Validator output end.");
        }

        try {
            //clean the error stream. Otherwise this might prevent the process from being terminated / cleared from the process table
            IOUtils.toString(process.getErrorStream());
        } catch (IOException ex) {
            logger.warn("Could not clear error stream.", ex);
        }

        process.waitFor();
        boolean valid = !hasNonEmptyLines; //validator is run in silent mode, so any output means plan is not valid.
        logger.info("Validation finished. Result is: " + valid);
        return new ValidationResult(valid, consoleOutputBuilder.toString());
    } catch (Exception ex) {
        if (planWriter != null) {
            try {
                planWriter.close();
            } catch (Exception ignored) {
            }
        }
        if (process != null) {
            process.destroy();
            try {
                //clean the streams so that the process does not hang in the process table
                IOUtils.toString(process.getErrorStream());
                IOUtils.toString(process.getInputStream());
            } catch (Exception ignored) {
                logger.warn("Could not clear output/error stream.", ignored);
            }
        }
        throw new ValidationException("Error during validation", ex);
    }
}

From source file:de.uzk.hki.da.grid.IrodsCommandLineConnector.java

/**
 * Gets checksum from ICAT for the newest instance destDao
 * @author Jens Peters/*from  ww w.j a  va 2  s  . c  o m*/
 * @param destDao
 * @return
 */
public String getChecksumOfLatestReplica(String destDao) {
    String ret = "";
    String commandAsArray[] = new String[] { "ils -L", destDao };
    String out = executeIcommand(commandAsArray);
    if (out.indexOf("ERROR") >= 0)
        throw new RuntimeException(" Get Checksum of " + destDao + " failed !");
    Scanner scanner = new Scanner(out);
    String data_name = FilenameUtils.getName(destDao);
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        if (line.contains(data_name)) {
            ret = line.substring(38, line.length());
        }
    }
    scanner.close();
    return ret;
}

From source file:org.caldfir.rawxml.tools.Relationship.java

private HashMap<String, String> buildRedirect() {
    HashMap<String, String> direct = new HashMap<String, String>();
    try {//from w w w.j a v  a  2  s  .com
        String s;
        FileReader f = new FileReader("Paramaters/directory.txt");
        Scanner scn = new Scanner(f);
        Pattern pSimp = Pattern.compile("[\"]([0-9a-zA-Z_]*)[\"][ \t]*[\"]([0-9a-zA-Z_]*)[\"]");
        Matcher mSimp;
        while (scn.hasNextLine()) {
            s = scn.nextLine();
            mSimp = pSimp.matcher(s);
            if (mSimp.matches()) {
                direct.put(mSimp.group(1), mSimp.group(2));
            }
        }
    } catch (FileNotFoundException e) {
        ErrorWriter ew = ErrorWriter.getInstance();
        ew.write("could not locate \"Paramaters/directory.txt\"");
    }
    //      direct.put("ATTACK",               "ATTACK");
    //      direct.put("BODY_APPEARANCE_MODIFIER",   "BODY_APPEARANCE_MODIFIER");
    //      direct.put("BP_APPEARANCE_MODIFIER",   "BODY_APPEARANCE_MODIFIER");
    //      direct.put("BODY_DETAIL_PLAN",         "BODY_DETAIL_PLAN");
    //      direct.put("CASTE",                  "CASTE");
    //      direct.put("SELECT_CASTE",            "CASTE");
    //      direct.put("COLOR",                  "COLOR");
    //      direct.put("CREATURE",               "CREATURE");
    //      direct.put("CAN_DO_INTERACTION",      "CAN_DO_INTERACTION");
    //      direct.put("CE_CAN_DO_INTERACTION",      "CAN_DO_INTERACTION");
    //      direct.put("CE_BODY_TRANSFORMATION",   "CE_BODY_TRANSFORMATION");
    //      direct.put("EXTRA_BUTCHER_OBJECT",      "EXTRA_BUTCHER_OBJECT");
    //      direct.put("OBJECT",               "OBJECT");
    //      direct.put("INTERACTION",            "INTERACTION");
    //      direct.put("I_TARGET",               "I_TARGET");
    //      direct.put("I_EFFECT",               "I_EFFECT");
    //      direct.put("I_SOURCE",               "I_SOURCE");
    //      direct.put("BASIC_MAT",               "MATERIAL");
    //      direct.put("MATERIAL_TEMPLATE",         "MATERIAL");
    //      direct.put("MATERIAL",               "MATERIAL");
    //      direct.put("SELECT_MATERIAL",         "MATERIAL");
    //      direct.put("USE_MATERIAL",            "MATERIAL");
    //      direct.put("USE_MATERIAL_TEMPLATE",      "MATERIAL");
    //      direct.put("INORGANIC",               "INORGANIC");
    //      direct.put("TISSUE_LAYER",            "TISSUE_LAYER");
    //      direct.put("SELECT_TISSUE_LAYER",      "TISSUE_LAYER");
    //      direct.put("SET_TL_GROUP",            "TISSUE_LAYER");
    //      direct.put("SET_BP_GROUP",            "SET_BP_GROUP");
    //      direct.put("TISSUE_LAYER_APPEARANCE_MODIFIER","TISSUE_LAYER_APPEARANCE_MODIFIER");
    //      direct.put("TISSUE_STYLE_UNIT",         "TISSUE_STYLE_UNIT");
    //      direct.put("TISSUE_TEMPLATE",         "TISSUE");
    //      direct.put("TISSUE",               "TISSUE");
    //      direct.put("SELECT_TISSUE",            "TISSUE");
    //      direct.put("USE_TISSUE_TEMPLATE",      "TISSUE");
    //      direct.put("USE_TISSUE",            "TISSUE");
    //      direct.put("TL_COLOR_MODIFIER",         "TL_COLOR_MODIFIER");
    //      direct.put("LAYS_EGGS",               "LAYS_EGGS");
    //      direct.put("SYNDROME",               "SYNDROME");
    //      direct.put("BP",                  "BP");
    //      direct.put("BODY",                  "BODY");
    //      direct.put("BUILDING_FURNACE",         "BUILDING_WORKSHOP");
    //      direct.put("BUILDING_WORKSHOP",         "BUILDING_WORKSHOP");
    //      direct.put("BUILD_ITEM",            "BUILD_ITEM");
    //      direct.put("CV_CONVERT_TAG",         "CV_CONVERT_TAG");
    //      direct.put("CREATURE_VARIATION",      "CREATURE_VARIATION");
    //      direct.put("COLOR_PATTERN",            "COLOR_PATTERN");
    //      direct.put("SHAPE",                  "SHAPE");
    //      direct.put("ENTITY",               "ENTITY");
    //      direct.put("WEAPON",               "WEAPON");
    //      direct.put("POSITION",               "POSITION");
    //      direct.put("TISSUE_STYLE",            "TISSUE_STYLE");
    //      direct.put("ITEM_WEAPON",            "ITEM_WEAPON");
    //      direct.put("ITEM_TOY",               "ITEM_TOY");
    //      direct.put("ITEM_TOOL",               "ITEM_TOOL");
    //      direct.put("ITEM_INSTRUMENT",         "ITEM_INSTRUMENT");
    //      direct.put("ITEM_TRAPCOMP",            "ITEM_TRAPCOMP");
    //      direct.put("ITEM_AMMO",               "ITEM_AMMO");
    //      direct.put("ITEM_SIEGEAMMO",         "ITEM_SIEGEAMMO");
    //      direct.put("ITEM_ARMOR",            "ITEM_ARMOR");
    //      direct.put("ITEM_GLOVES",            "ITEM_ARMOR");
    //      direct.put("ITEM_SHOES",            "ITEM_ARMOR");
    //      direct.put("ITEM_SHIELD",            "ITEM_ARMOR");
    //      direct.put("ITEM_HELM",               "ITEM_ARMOR");
    //      direct.put("ITEM_PANTS",            "ITEM_ARMOR");
    //      direct.put("ITEM_FOOD",               "ITEM_FOOD");
    //      direct.put("SYMBOL",               "SYMBOL");
    //      direct.put("TRANSLATION",            "TRANSLATION");
    //      direct.put("WORD",                  "WORD");
    //      direct.put("NOUN",                  "NOUN");
    //      direct.put("ADJ",                  "ADJ");
    //      direct.put("VERB",                  "VERB");
    //      direct.put("PREFIX",               "PREFIX");
    //      direct.put("PLANT",                  "PLANT");
    //      direct.put("REACTION",               "REACTION");
    //      direct.put("REAGENT",               "REAGENT");
    //      direct.put("PRODUCT",               "PRODUCT");
    return direct;
}

From source file:jp.ikedam.jenkins.plugins.extensible_choice_parameter.DatabaseChoiceListProvider.java

/**
 * /*w  w w  . ja  v a  2s .  c o m*/
 * @return
 */
private List<String> performDbQuery() {

    Connection conn = null;
    ResultSet resultat = null;
    List<String> resultList = new ArrayList<String>();
    try {
        String driver = getJdbcDriver();
        if (driver == null || StringUtils.isEmpty(driver)) {
            LOGGER.log(Level.WARNING, "Invalid driver");
        }

        Class.forName(driver);

        String user = getDbUsername();
        if (user == null || StringUtils.isEmpty(user)) {
            LOGGER.log(Level.WARNING, "Invalid user");
        }

        String password = getDbPassword();
        if (password == null || StringUtils.isEmpty(password)) {
            LOGGER.log(Level.WARNING, "Invalid password");
        }

        String urlBase = getJdbcUrl();
        if (urlBase == null || StringUtils.isEmpty(urlBase)) {
            LOGGER.log(Level.WARNING, "Invalid JDBC URL");
        }

        String colomndb = getDbColumn();
        if (colomndb == null || StringUtils.isEmpty(colomndb)) {
            LOGGER.log(Level.WARNING, "Invalid column");
        }

        String namedb = getDbName();
        if (namedb == null || StringUtils.isEmpty(namedb)) {
            LOGGER.log(Level.WARNING, "Invalid DB name");
        }

        String tabledb = getDbTable();
        if (tabledb == null || StringUtils.isEmpty(tabledb)) {
            LOGGER.log(Level.WARNING, "table database invalid");
        }

        conn = DriverManager.getConnection(urlBase, user, password);

        // By default, a SELECT * is performed
        String selectQuery = "select " + colomndb + " from " + namedb + "." + tabledb;

        // Use plain old JDBC to build and execute the query against the configured db
        Statement statement = conn.createStatement();
        boolean result = statement.execute(selectQuery);
        if (result) {
            resultat = statement.executeQuery(selectQuery);
            while (resultat.next()) {
                resultList.add(resultat.getString(1));
            }
        } else {
            LOGGER.log(Level.WARNING, "No result found with the query: " + selectQuery);
        }
    } catch (SQLException se) {
        LOGGER.log(Level.SEVERE, "Unable to access the database: " + dbName + "." + se);
    } catch (ClassNotFoundException e) {
        LOGGER.log(Level.SEVERE, "The driver " + jdbcDriver + " cannot be found in the classpath.");
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Unable to access the database: " + dbName + "." + e);
    } finally {
        try {
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException se) {
            LOGGER.log(Level.SEVERE, "Fermeture de connection impossible, SQLException : " + se);
        }
    }

    // If no results are returned, read values from the fallback file if configured
    if (resultList.isEmpty()) {

        Scanner scanner = null;
        try {
            scanner = new Scanner(new FileInputStream(getFallbackFilePath()));
            while (scanner.hasNextLine()) {
                String env = scanner.nextLine().trim();
                if (StringUtils.isNotBlank(env)) {
                    resultList.add(env);
                }
            }
        } catch (FileNotFoundException e) {
            LOGGER.log(Level.WARNING, "Unable to read the fallback file: " + e);
        } finally {
            if (scanner != null) {
                scanner.close();
            }
        }
    }

    // Perform alphabetical sorting on results
    Collections.sort(resultList);

    return resultList;
}

From source file:com.l2jfree.gameserver.datatables.ExtractableSkillsData.java

private ExtractableSkillsData() {
    _items.clear();/*from  ww  w  . j  a v  a  2 s. co m*/

    Scanner s;

    try {
        s = new Scanner(new File(Config.DATAPACK_ROOT, "data/extractable_skills.csv"));
    } catch (Exception e) {
        _log.warn("Extractable items data: Can not find '" + Config.DATAPACK_ROOT
                + "data/extractable_skills.csv'");
        return;
    }

    int lineCount = 0;

    while (s.hasNextLine()) {
        lineCount++;

        String line = s.nextLine().trim();

        if (line.startsWith("#"))
            continue;
        else if (line.isEmpty())
            continue;

        String[] lineSplit = line.split(";");
        boolean ok = true;
        int skillID = 0;
        int skillLevel = 0;

        try {
            skillID = Integer.parseInt(lineSplit[0]);
            skillLevel = Integer.parseInt(lineSplit[1]);
        } catch (Exception e) {
            _log.warn("Extractable skills data: Error in line " + lineCount
                    + " -> invalid item id or wrong seperator after skill id!");
            _log.warn("      " + line);
            ok = false;
        }

        L2Skill skill = SkillTable.getInstance().getInfo(skillID, skillLevel);
        if (skill == null) {
            _log.warn("Extractable skills data: Error in line " + lineCount + " -> skill is null!");
            _log.warn("      " + line);
            ok = false;
        }

        if (!ok)
            continue;

        FastList<L2ExtractableProductItem> product_temp = new FastList<L2ExtractableProductItem>();

        for (int i = 1; i < lineSplit.length - 1; i++) {
            ok = true;

            String[] lineSplit2 = lineSplit[i + 1].split(",");

            if (lineSplit2.length < 3) {
                _log.warn("Extractable items data: Error in line " + lineCount + " -> wrong seperator!");
                _log.warn("      " + line);
                ok = false;
            }

            if (!ok)
                continue;

            int[] production = null;
            int[] amount = null;
            int chance = 0;

            try {
                int k = 0;
                production = new int[(lineSplit2.length - 1) / 2];
                amount = new int[(lineSplit2.length - 1) / 2];
                for (int j = 0; j < lineSplit2.length - 1; j++) {
                    production[k] = Integer.parseInt(lineSplit2[j]);
                    amount[k] = Integer.parseInt(lineSplit2[j += 1]);
                    k++;
                }

                chance = Integer.parseInt(lineSplit2[lineSplit2.length - 1]);
            } catch (Exception e) {
                _log.warn("Extractable skills data: Error in line " + lineCount
                        + " -> incomplete/invalid production data or wrong seperator!");
                _log.warn("      " + line);
                ok = false;
            }

            if (!ok)
                continue;

            L2ExtractableProductItem product = new L2ExtractableProductItem(production, amount, chance);
            product_temp.add(product);
        }

        int fullChances = 0;

        for (L2ExtractableProductItem Pi : product_temp)
            fullChances += Pi.getChance();

        if (fullChances > 100) {
            _log.warn("Extractable skills data: Error in line " + lineCount
                    + " -> all chances together are more then 100!");
            _log.warn("      " + line);
            continue;
        }
        int hash = SkillTable.getSkillUID(skill);
        L2ExtractableSkill product = new L2ExtractableSkill(hash, product_temp);
        _items.put(hash, product);
    }

    s.close();
    _log.info("Extractable items data: Loaded " + _items.size() + " extractable skills!");
}

From source file:org.mrgeo.hdfs.tile.SplitFile.java

protected boolean hasPartitionNames(final InputStream splitFileInputStream) {
    final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(splitFileInputStream)));
    try {//from  w  w  w.ja  v  a 2 s.  c  o  m
        while (in.hasNextLine()) {
            final long split = ByteBuffer.wrap(Base64.decodeBase64(in.nextLine().getBytes())).getLong();
            return (split == HAS_PARTITION_NAMES);
        }
    } finally {
        in.close();
    }
    return false;
}

From source file:org.jbpm.designer.server.EditorHandler.java

private String readFile(String pathname) throws IOException {
    StringBuilder fileContents = new StringBuilder();
    Scanner scanner = new Scanner(new File(pathname), "UTF-8");
    String lineSeparator = System.getProperty("line.separator");
    try {//w ww  .j ava 2 s.co  m
        while (scanner.hasNextLine()) {
            fileContents.append(scanner.nextLine() + lineSeparator);
        }
        return fileContents.toString();
    } finally {
        scanner.close();
    }
}

From source file:com.joliciel.talismane.other.standoff.StandoffReader.java

public StandoffReader(Scanner scanner) {
    PosTagSet posTagSet = TalismaneSession.getPosTagSet();

    Map<Integer, StandoffToken> sortedTokens = new TreeMap<Integer, StandoffReader.StandoffToken>();
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        if (line.startsWith("T")) {

            String[] parts = line.split("[\\t]");
            String id = parts[0];
            String[] posTagParts = parts[1].split(" ");
            String posTagCode = posTagParts[0].replace('_', '+');
            int startPos = Integer.parseInt(posTagParts[1]);
            String text = parts[2];

            PosTag posTag = null;//from  w w  w.j  a  va2 s.  co m
            if (posTagCode.equalsIgnoreCase(PosTag.ROOT_POS_TAG_CODE)) {
                posTag = PosTag.ROOT_POS_TAG;
            } else {
                try {
                    posTag = posTagSet.getPosTag(posTagCode);
                } catch (UnknownPosTagException upte) {
                    throw new TalismaneException("Unknown posTag on line " + lineNumber + ": " + posTagCode);
                }
            }

            StandoffToken token = new StandoffToken();
            token.posTag = posTag;
            token.text = text;
            token.id = id;

            sortedTokens.put(startPos, token);
            tokenMap.put(id, token);

        } else if (line.startsWith("R")) {

            String[] parts = line.split("[\\t :]");
            String id = parts[0];
            String label = parts[1];
            String headId = parts[3];
            String dependentId = parts[5];
            StandoffRelation relation = new StandoffRelation();
            relation.fromToken = headId;
            relation.toToken = dependentId;
            relation.label = label;
            idRelationMap.put(id, relation);
            relationMap.put(dependentId, relation);
        } else if (line.startsWith("#")) {
            String[] parts = line.split("\t");
            String itemId = parts[1].substring("AnnotatorNotes ".length());
            String note = parts[2];
            notes.put(itemId, note);
        }
    }

    for (String itemId : notes.keySet()) {
        String comment = notes.get(itemId);
        if (itemId.startsWith("R")) {
            StandoffRelation relation = idRelationMap.get(itemId);
            relation.comment = comment;
        } else {
            StandoffToken token = tokenMap.get(itemId);
            token.comment = comment;
        }
    }

    List<StandoffToken> currentSentence = null;
    for (StandoffToken token : sortedTokens.values()) {
        if (token.text.equals("ROOT")) {
            if (currentSentence != null)
                sentences.add(currentSentence);
            currentSentence = new ArrayList<StandoffReader.StandoffToken>();
        }
        currentSentence.add(token);
    }
    if (currentSentence != null)
        sentences.add(currentSentence);
}

From source file:edu.ucuenca.authorsdisambiguation.nwd.NWD.java

public synchronized String Http2(String s, Map<String, String> mp, String prefix)
        throws SQLException, IOException {
    String md = s + mp.toString();
    String get = Cache.getInstance().get(prefix + md);
    String resp = "";
    if (get != null) {
        resp = get;//from www.  j  a v a 2s  .co m
    } else {
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod(s);
        method.getParams().setContentCharset("utf-8");

        //Add any parameter if u want to send it with Post req.
        for (Entry<String, String> mcc : mp.entrySet()) {
            method.addParameter(mcc.getKey(), mcc.getValue());
        }

        int statusCode = client.executeMethod(method);

        if (statusCode != -1) {
            InputStream in = method.getResponseBodyAsStream();
            final Scanner reader = new Scanner(in, "UTF-8");
            while (reader.hasNextLine()) {
                final String line = reader.nextLine();
                resp += line + "\n";
            }
            reader.close();
            Cache.getInstance().put(prefix + md, resp);

        }

    }

    return resp;
}

From source file:algorithm.laddress.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//from ww  w . j  a  va2 s .c o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    // Create path components to save the file
    final String path = "C:\\Users\\Rads\\Documents\\NetBeansProjects\\capstone\\src\\java\\algorithm\\";
    final Part filePart = request.getPart("file");
    final String fileName = getFileName(filePart);

    OutputStream out = null;
    InputStream filecontent = null;
    final PrintWriter writer = response.getWriter();

    try {
        out = new FileOutputStream(new File(path + File.separator + fileName));
        filecontent = filePart.getInputStream();

        int read = 0;
        final byte[] bytes = new byte[1024];

        while ((read = filecontent.read(bytes)) != -1) {
            out.write(bytes, 0, read);
        }
        // writer.println("New file " + fileName + " created at " + path);
        LOGGER.log(Level.INFO, "File{0}being uploaded to {1}", new Object[] { fileName, path });
    } catch (FileNotFoundException fne) {
        writer.println("You either did not specify a file to upload or are "
                + "trying to upload a file to a protected or nonexistent " + "location.");
        writer.println("<br/> ERROR: " + fne.getMessage());

        LOGGER.log(Level.SEVERE, "Problems during file upload. Error: {0}", new Object[] { fne.getMessage() });
    }

    Scanner s = null;
    String listOfAddresses = "";
    try {
        String address = fileName;
        String dname = "C:\\Users\\Rads\\Documents\\NetBeansProjects\\capstone\\src\\java\\algorithm\\"
                + address;
        File f = new File(dname);
        s = new Scanner(f);
        //s.useDelimiter(",");   //Use the normal expression and exclude data we imagine they are not "WORDS"
    } catch (FileNotFoundException e) {

    }
    while (s.hasNextLine()) {
        String[] curr = s.nextLine().split(",");
        listOfAddresses = listOfAddresses + "<br/>" + curr[1];
    }
    String nextView = "user.jsp";
    request.setAttribute("Address", listOfAddresses);
    RequestDispatcher view = request.getRequestDispatcher(nextView);
    view.forward(request, response);
}