Example usage for java.util Scanner nextLine

List of usage examples for java.util Scanner nextLine

Introduction

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

Prototype

public String nextLine() 

Source Link

Document

Advances this scanner past the current line and returns the input that was skipped.

Usage

From source file:com.maxl.java.aips2xml.Aips2Xml.java

static void extractPackageInfo() {
    try {/*from   www.j  a v  a  2  s . co  m*/
        long startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing packages xls ... ");
        // Load Swissmedic xls file
        FileInputStream packages_file = new FileInputStream(FILE_PACKAGES_XLS);
        // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
        HSSFWorkbook packages_workbook = new HSSFWorkbook(packages_file);
        // Get first sheet from workbook
        HSSFSheet packages_sheet = packages_workbook.getSheetAt(0);
        // Iterate through all rows of first sheet
        Iterator<Row> rowIterator = packages_sheet.iterator();

        int num_rows = 0;
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            if (num_rows > 3) {
                String swissmedic_no5 = ""; // SwissmedicNo5 registration number (5 digits)
                String sequence_name = "";
                String package_id = "";
                String swissmedic_no8 = ""; // SwissmedicNo8 = SwissmedicNo5 + Package id (8 digits)
                String heilmittel_code = "";
                String package_size = "";
                String package_unit = "";
                String swissmedic_cat = "";
                String application_area = "";
                String public_price = "";
                String exfactory_price = "";
                String therapeutic_index = "";
                String withdrawn_str = "";
                String speciality_str = "";
                String plimitation_str = "";
                String add_info_str = ""; // Contains additional information separated by ;

                // 0: Zulassungsnnr, 1: Sequenz, 2: Sequenzname, 3: Zulassunginhaberin, 4: T-Nummer, 5: ATC-Code, 6: Heilmittelcode
                // 7: Erstzulassung Prparat, 8: Zulassungsdatum Sequenz, 9: Gltigkeitsdatum, 10: Verpackung, 11: Packungsgrsse
                // 12: Einheit, 13: Abgabekategorie, 14: Wirkstoff, 15: Zusammensetzung, 16: Anwendungsgebiet Prparat, 17: Anwendungsgebiet Sequenz

                swissmedic_no5 = getAnyValue(row.getCell(0)); // Swissmedic registration number (5 digits)
                sequence_name = getAnyValue(row.getCell(2)); // Sequence name
                heilmittel_code = getAnyValue(row.getCell(6));
                package_size = getAnyValue(row.getCell(11));
                package_unit = getAnyValue(row.getCell(12));
                swissmedic_cat = getAnyValue(row.getCell(13));
                application_area = getAnyValue(row.getCell(16));

                if (row.getCell(10) != null) {
                    package_id = getAnyValue(row.getCell(10));
                    swissmedic_no8 = swissmedic_no5 + package_id;
                    // Fill in row
                    ArrayList<String> pack = new ArrayList<String>();
                    pack.add(swissmedic_no5); // 0
                    pack.add(sequence_name); // 1
                    pack.add(heilmittel_code); // 2
                    pack.add(package_size); // 3
                    pack.add(package_unit); // 4
                    pack.add(swissmedic_cat); // 5
                    if (!application_area.isEmpty())
                        pack.add(application_area + " (Swissmedic)\n"); // 6 = swissmedic + bag
                    else
                        pack.add("");
                    pack.add(public_price); // 7
                    pack.add(exfactory_price); // 8
                    pack.add(therapeutic_index); // 9
                    pack.add(withdrawn_str); // 10
                    pack.add(speciality_str); // 11   
                    pack.add(plimitation_str); // 12
                    pack.add(add_info_str); // 13

                    package_info.put(swissmedic_no8, pack);
                }
            }
            num_rows++;
        }
        long stopTime = System.currentTimeMillis();
        if (SHOW_LOGS) {
            System.out.println(
                    (package_info.size() + 1) + " packages in " + (stopTime - startTime) / 1000.0f + " sec");
        }
        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing atc classes xls ... ");
        if (DB_LANGUAGE.equals("de")) {
            // Load ATC classes xls file
            FileInputStream atc_classes_file = new FileInputStream(FILE_ATC_CLASSES_XLS);
            // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
            HSSFWorkbook atc_classes_workbook = new HSSFWorkbook(atc_classes_file);
            // Get first sheet from workbook
            HSSFSheet atc_classes_sheet = atc_classes_workbook.getSheetAt(1);
            // Iterate through all rows of first sheet
            rowIterator = atc_classes_sheet.iterator();

            num_rows = 0;
            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();
                if (num_rows > 2) {
                    String atc_code = "";
                    String atc_class = "";
                    if (row.getCell(0) != null) {
                        atc_code = row.getCell(0).getStringCellValue().replaceAll("\\s", "");
                    }
                    if (row.getCell(2) != null) {
                        atc_class = row.getCell(2).getStringCellValue();
                    }
                    // Build a full map atc code to atc class
                    if (atc_code.length() > 0) {
                        atc_map.put(atc_code, atc_class);
                    }
                }
                num_rows++;
            }
        } else if (DB_LANGUAGE.equals("fr")) {
            // Load multilinguagl ATC classes txt file
            String atc_classes_multi = readFromFile(FILE_ATC_MULTI_LINGUAL_TXT);
            // Loop through all lines
            Scanner scanner = new Scanner(atc_classes_multi);
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                List<String> atc_class = Arrays.asList(line.split(": "));
                String atc_code = atc_class.get(0);
                String[] atc_classes_str = atc_class.get(1).split(";");
                String atc_class_french = atc_classes_str[1].trim();
                atc_map.put(atc_code, atc_class_french);
            }
            scanner.close();
        }
        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out
                    .println((atc_map.size() + 1) + " classes in " + (stopTime - startTime) / 1000.0f + " sec");
        // Load Refdata xml file
        File refdata_xml_file = null;
        if (DB_LANGUAGE.equals("de"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_DE_XML);
        else if (DB_LANGUAGE.equals("fr"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_FR_XML);
        else {
            System.err.println("ERROR: DB_LANGUAGE undefined");
            System.exit(1);
        }
        FileInputStream refdata_fis = new FileInputStream(refdata_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Unmarshalling Refdata Pharma " + DB_LANGUAGE + " ... ");

        JAXBContext context = JAXBContext.newInstance(Pharma.class);
        Unmarshaller um = context.createUnmarshaller();
        Pharma refdataPharma = (Pharma) um.unmarshal(refdata_fis);
        List<Pharma.ITEM> pharma_list = refdataPharma.getItem();

        String smno8;
        for (Pharma.ITEM pharma : pharma_list) {
            String ean_code = pharma.getGtin();
            if (ean_code.length() == 13) {
                smno8 = ean_code.substring(4, 12);
                // Extract pharma corresponding to swissmedicno8
                ArrayList<String> pi_row = package_info.get(smno8);
                // Replace sequence_name
                if (pi_row != null) {
                    if (pharma.getAddscr().length() > 0)
                        pi_row.set(1, pharma.getDscr() + ", " + pharma.getAddscr());
                    else
                        pi_row.set(1, pharma.getDscr());
                    if (pharma.getStatus().equals("I")) {
                        if (DB_LANGUAGE.equals("de"))
                            pi_row.set(10, "a.H.");
                        else if (DB_LANGUAGE.equals("fr"))
                            pi_row.set(10, "p.c.");
                    }
                } else {
                    if (SHOW_ERRORS)
                        System.err.println(">> Does not exist in BAG xls: " + smno8 + " (" + pharma.getDscr()
                                + ", " + pharma.getAddscr() + ")");
                }

            } else if (ean_code.length() < 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too short: " + ean_code + ": " + pharma.getDscr());
            } else if (ean_code.length() > 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too long: " + ean_code + ": " + pharma.getDscr());
            }
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(pharma_list.size() + " medis in " + (stopTime - startTime) / 1000.0f + " sec");

        // Load BAG xml file               
        File bag_xml_file = new File(FILE_PREPARATIONS_XML);
        FileInputStream fis_bag = new FileInputStream(bag_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing preparations xml ... ");

        context = JAXBContext.newInstance(Preparations.class);
        um = context.createUnmarshaller();
        Preparations prepInfos = (Preparations) um.unmarshal(fis_bag);
        List<Preparations.Preparation> prep_list = prepInfos.getPreparations();

        int num_preparations = 0;
        for (Preparations.Preparation prep : prep_list) {
            String swissmedicno5_str = prep.getSwissmedicNo5();
            if (swissmedicno5_str != null) {
                String orggencode_str = ""; // "O", "G" or empty -> ""
                String flagSB20_str = ""; // "Y" -> 20% or "N" -> 10%                     
                if (prep.getOrgGenCode() != null)
                    orggencode_str = prep.getOrgGenCode();
                if (prep.getFlagSB20() != null) {
                    flagSB20_str = prep.getFlagSB20();
                    if (flagSB20_str.equals("Y")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 20%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 20%";
                    } else if (flagSB20_str.equals("N")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 10%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 10%";
                    } else
                        flagSB20_str = "";
                }
                add_info_map.put(swissmedicno5_str, orggencode_str + ";" + flagSB20_str);
            }

            List<Preparation.Packs> packs_list = prep.getPacks();
            for (Preparation.Packs packs : packs_list) {
                // Extract codes for therapeutic index / classification
                String bag_application = "";
                String therapeutic_code = "";
                List<Preparations.Preparation.ItCodes> itcode_list = prep.getItCodes();
                for (Preparations.Preparation.ItCodes itc : itcode_list) {
                    List<Preparations.Preparation.ItCodes.ItCode> code_list = itc.getItCode();
                    int index = 0;
                    for (Preparations.Preparation.ItCodes.ItCode code : code_list) {
                        if (index == 0) {
                            if (DB_LANGUAGE.equals("de"))
                                therapeutic_code = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                therapeutic_code = code.getDescriptionFr();
                        } else {
                            if (DB_LANGUAGE.equals("de"))
                                bag_application = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                bag_application = code.getDescriptionFr();
                        }
                        index++;
                    }
                }
                // Generate new package info
                List<Preparation.Packs.Pack> pack_list = packs.getPack();
                for (Preparation.Packs.Pack pack : pack_list) {
                    // Get SwissmedicNo8 and used it as a key to extract all the relevant package info
                    String swissMedicNo8 = pack.getSwissmedicNo8();
                    ArrayList<String> pi_row = package_info.get(swissMedicNo8);
                    // Preparation also in BAG xml file (we have a price)
                    if (pi_row != null) {
                        // Update Swissmedic catory if necessary ("N->A", Y->"A+")
                        if (pack.getFlagNarcosis().equals("Y"))
                            pi_row.set(5, pi_row.get(5) + "+");
                        // Extract point limitations
                        List<Preparations.Preparation.Packs.Pack.PointLimitations> point_limits = pack
                                .getPointLimitations();
                        for (Preparations.Preparation.Packs.Pack.PointLimitations limits : point_limits) {
                            List<Preparations.Preparation.Packs.Pack.PointLimitations.PointLimitation> plimits_list = limits
                                    .getPointLimitation();
                            if (plimits_list.size() > 0)
                                if (plimits_list.get(0) != null)
                                    pi_row.set(12, ", LIM" + plimits_list.get(0).getPoints() + "");
                        }
                        // Extract exfactory and public prices
                        List<Preparations.Preparation.Packs.Pack.Prices> price_list = pack.getPrices();
                        for (Preparations.Preparation.Packs.Pack.Prices price : price_list) {
                            List<Preparations.Preparation.Packs.Pack.Prices.PublicPrice> public_price = price
                                    .getPublicPrice();
                            List<Preparations.Preparation.Packs.Pack.Prices.ExFactoryPrice> exfactory_price = price
                                    .getExFactoryPrice();
                            if (exfactory_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(exfactory_price.get(0).getPrice());
                                    String ep = String.format("%.2f", f);
                                    pi_row.set(8, "CHF " + ep);
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (exfactory price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }

                            }
                            if (public_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(public_price.get(0).getPrice());
                                    String pp = String.format("%.2f", f);
                                    pi_row.set(7, "CHF " + pp);
                                    if (DB_LANGUAGE.equals("de"))
                                        pi_row.set(11, ", SL");
                                    else if (DB_LANGUAGE.equals("fr"))
                                        pi_row.set(11, ", LS");
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (public price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }
                            }
                            // Add application area and therapeutic code
                            if (!bag_application.isEmpty())
                                pi_row.set(6, pi_row.get(6) + bag_application + " (BAG)");
                            pi_row.set(9, therapeutic_code);
                        }
                    }
                }
            }
            num_preparations++;
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(
                    num_preparations + " preparations in " + (stopTime - startTime) / 1000.0f + " sec");

        // Loop through all SwissmedicNo8 numbers
        for (Map.Entry<String, ArrayList<String>> entry : package_info.entrySet()) {
            String swissmedicno8 = entry.getKey();
            ArrayList<String> pi_row = entry.getValue();
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:com.joliciel.talismane.GenericLanguageImplementation.java

private String getStringFromScanner(Scanner scanner) {
    StringBuilder sb = new StringBuilder();
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        sb.append(line + "\n");
    }/*ww w  . java  2s .  c om*/
    return sb.toString();
}

From source file:org.motechproject.mobile.imp.serivce.oxd.FormDefinitionServiceImpl.java

private String getFileContent(String fileName) {
    StringBuilder builder = new StringBuilder();
    Scanner scanner;
    try {/* w  w  w .  jav a 2s .  c o  m*/
        scanner = new Scanner(new File(fileName));
        scanner.useDelimiter("\n");
        while (scanner.hasNextLine()) {
            builder.append(scanner.nextLine() + "\n");
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return builder.toString();
}

From source file:ml.shifu.shifu.core.processor.PostTrainModelProcessor.java

private List<Integer> getFeatureImportance(SourceType source, String output) throws IOException {
    List<Integer> featureImportance = new ArrayList<Integer>();
    List<Scanner> scanners = null;
    try {/*from  w ww . ja  v  a  2s  .c o m*/
        scanners = ShifuFileUtils.getDataScanners(output, source, new PathFilter() {
            @Override
            public boolean accept(Path path) {
                return path.toString().contains("part-r-");
            }
        });

        for (Scanner scanner : scanners) {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine().trim();
                String[] keyValues = line.split("\t");
                String key = keyValues[0];
                featureImportance.add(Integer.parseInt(key));
            }
        }
    } finally {
        // release
        closeScanners(scanners);
    }
    return featureImportance;
}

From source file:com.santhoshknn.sudoku.GridExtractor.java

/**
 * <p>//from w  w w .  j  a  v a  2s.  c  o m
 * Parses the supplied file to extract a 9x9 grid of integers substituting
 * the supplied x with a 0
 * </p>
 * <b>Note:</b>Used internally for testing with various data. REST API uses
 * the operation above
 *
 * @param input
 * @return extracted grid if valid input, null otherwise
 */
public GridResponse parseFromFile(final String fileName) {
    int[][] grid = new int[9][9]; // default 0 vals
    GridResponse response = new GridResponse();
    Scanner scanner = null;
    String error = null;
    try {
        URL url = getClass().getResource(fileName);
        log.info("Reading input file [{}]", url.getFile());
        scanner = new Scanner(new File(url.getPath()));
        int row = 0;
        while (scanner.hasNext()) {
            int col = 0;
            String line = scanner.nextLine();
            // delete whitespaces added for cosmetic purpose
            line = StringUtils.deleteWhitespace(line);
            if (line.isEmpty())
                continue; // Sanitize input. Remove line added for
                          // readability
                          // fail if line's length!=9
            if (line.length() != 9) {
                error = INVALID_CHARS_IN_FILE + ":" + (row + 1);
                break;
            }

            for (int i = 0; i < line.length(); i++) {
                //log.info("Row [{}] Char is [{}]",row,line.charAt(i));
                if (Character.isDigit(line.charAt(i))) {
                    int number = Character.getNumericValue(line.charAt(i));
                    grid[row][col] = number;
                } else {
                    grid[row][col] = 0;
                }
                col++;
            }
            if (row == 9)
                break;
            row++;
        }
    } catch (FileNotFoundException e) {
        log.error("Error reading file [{}]", fileName, e);
    } finally {
        if (scanner != null)
            scanner.close();
    }
    if (null == error) {
        response.setGrid(grid);
    } else {
        response.setError(error);
        log.error(error);
    }
    return response;
}

From source file:net.sf.jaceko.mock.util.FileReader.java

public String readFileContents(final String fileName) {
    final StringBuilder text = new StringBuilder();
    final String newLine = System.getProperty("line.separator");
    Scanner scanner = null;
    try {//from   w w  w. j  av  a2s.c o m
        final InputStream resourceAsStream = FileReader.class.getClassLoader().getResourceAsStream(fileName);
        if (resourceAsStream == null) {
            LOG.error("File not found: " + fileName);
            return null;
        } else {
            LOG.info(fileName + " found in classpath");
        }
        scanner = new Scanner(resourceAsStream);
        while (scanner.hasNextLine()) {
            text.append(scanner.nextLine() + newLine);
        }
    } catch (final Exception e) {
        LOG.error("Problem reading file : " + fileName, e);
        return null;
    } finally {
        if (scanner != null) {
            scanner.close();
        }
    }

    return text.toString();
}

From source file:hmp.HMPClassiferSummary.java

private ResultContainer getRawRdpResults(String fileName, ReadContainer reads)
        throws FileNotFoundException, SQLException {
    System.out.println("Getting RDP Results");
    ResultContainer results = new ResultContainer((float) cutoff);
    Scanner scan = new Scanner(new File(fileName));
    while (scan.hasNext()) {
        results.addResult(new Result(scan.nextLine(), (float) cutoff, readDelimiter, readIdIndex));
    }//from   www  .java2  s. com

    /*
     * Add read object to each rdp result
     * Used for stats calculation later on
     */
    for (Result r : results.getResults()) {
        r.addRead(reads.getRead(r.getId()));
    }
    //
    //        /*
    //         * Add rank to reach result entry
    //         */
    //        System.out.println("Adding ranks for each taxa entry");
    //        for (Result r : results.getResults()) {
    //            for (ResultEntry e : r.getEntries()) {
    //                e.setLevel(getTaxaLevelFromDB(e.getTaxa(), e.getIndex()));
    //            }
    //
    //            /*
    //             * get level for processed data, using taxa information from
    //             * pre processed array.  this ensures that unclassified entries
    //             * are at the proper level
    //             */
    //
    //            for (ResultEntry e : r.getProcessedEntries()) {
    //                e.setLevel(getTaxaLevelFromDB(r.getEntries()[e.getIndex()].getTaxa(), e.getIndex()));
    //            }
    //        }

    return results;
}

From source file:ml.shifu.shifu.core.processor.PostTrainModelProcessor.java

private void updateAvgScores(SourceType source, String postTrainOutputPath) throws IOException {
    List<Scanner> scanners = null;
    try {/*from  ww  w.  j  a v a 2 s .c o m*/
        scanners = ShifuFileUtils.getDataScanners(postTrainOutputPath, source, new PathFilter() {
            @Override
            public boolean accept(Path path) {
                return path.toString().contains("part-r-");
            }
        });

        for (Scanner scanner : scanners) {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine().trim();
                String[] keyValues = line.split("\t");
                String key = keyValues[0];
                String value = keyValues[1];
                ColumnConfig config = this.columnConfigList.get(Integer.parseInt(key));
                List<Integer> binAvgScores = new ArrayList<Integer>();
                String[] avgScores = value.split(",");
                for (int i = 0; i < avgScores.length; i++) {
                    binAvgScores.add(Integer.parseInt(avgScores[i]));
                }
                config.setBinAvgScore(binAvgScores);
            }
        }
    } finally {
        // release
        closeScanners(scanners);
    }
}

From source file:com.laex.cg2d.screeneditor.handlers.RenderHandler.java

/**
 * the command has been executed, so extract extract the needed information
 * from the application context./*from   www . j a  v  a 2s.c  o  m*/
 * 
 * @param event
 *          the event
 * @return the object
 * @throws ExecutionException
 *           the execution exception
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    final IEditorPart editorPart = window.getActivePage().getActiveEditor();

    editorPart.doSave(new NullProgressMonitor());

    validate(window.getShell());

    // Eclipse Jobs API
    final Job job = new Job("Render Game") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

            if (monitor.isCanceled()) {
                return Status.CANCEL_STATUS;
            }

            try {
                IFile file = ((IFileEditorInput) editorPart.getEditorInput()).getFile();

                monitor.beginTask("Building rendering command", 5);
                ILog log = Activator.getDefault().getLog();

                String mapFile = file.getLocation().makeAbsolute().toOSString();
                String controllerFile = file.getLocation().removeFileExtension().addFileExtension("lua")
                        .makeAbsolute().toOSString();

                String[] command = buildRunnerCommandFromProperties(mapFile, controllerFile);
                monitor.worked(5);

                monitor.beginTask("Rendering external", 5);

                ProcessBuilder pb = new ProcessBuilder(command);
                Process p = pb.start();

                monitor.worked(4);
                Scanner scn = new Scanner(p.getErrorStream());
                while (scn.hasNext() && !monitor.isCanceled()) {

                    if (monitor.isCanceled()) {
                        throw new InterruptedException("Cancelled");
                    }

                    log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, scn.nextLine()));
                }
                monitor.worked(5);

                monitor.done();
                this.done(Status.OK_STATUS);
                return Status.OK_STATUS;

            } catch (RuntimeException e) {
                return handleException(e);
            } catch (IOException e) {
                return handleException(e);
            } catch (CoreException e) {
                return handleException(e);
            } catch (InterruptedException e) {
                return handleException(e);
            }
        }

        private IStatus handleException(Exception e) {
            Activator.log(e);
            return Status.CANCEL_STATUS;
        }
    };

    job.setUser(true);
    job.setPriority(Job.INTERACTIVE);
    job.schedule();

    return null;
}

From source file:hmp.HMPClassiferSummary.java

private ReadContainer getReads(File file) throws FileNotFoundException {
    String readFileName = cli.getOptionValue("sourceDir") + File.separator
            + file.getName().replace(fileSuffix, "");
    File readFile = new File(readFileName);
    System.out.println("Getting reads from " + readFile.getName() + " size=" + readFile.length() + " bytes");
    ReadContainer container = new ReadContainer();

    Scanner scan = new Scanner(readFile);
    String line = null;//from  www .java 2 s.  c  o  m
    Read read = null;
    while (scan.hasNext()) {
        line = scan.nextLine();
        if (!line.isEmpty()) {
            if (line.startsWith(">")) {
                read = new Read(line, readDelimiter, String.valueOf(readIdIndex));
                container.addRead(read);
            } else {
                read.addSequence(line);
            }
        }
    }
    System.out.println("Read " + readFile.getName() + " reads=" + container.getNumberOfReads());
    return container;
}