Example usage for java.lang Float parseFloat

List of usage examples for java.lang Float parseFloat

Introduction

In this page you can find the example usage for java.lang Float parseFloat.

Prototype

public static float parseFloat(String s) throws NumberFormatException 

Source Link

Document

Returns a new float initialized to the value represented by the specified String , as performed by the valueOf method of class Float .

Usage

From source file:net.estinet.gFeatures.Feature.gHub.config.gHubConfig.java

public void retrieve() {
    try {//  w ww  .  j  a v a 2 s  .  c  om
        List<String> list = getLines(new File("plugins/gFeatures/gHub/spawn.txt"));
        gHub.spawn = new Location(Bukkit.getWorld(list.get(0)), Double.parseDouble(list.get(1)),
                Double.parseDouble(list.get(2)), Double.parseDouble(list.get(3)), Float.parseFloat(list.get(4)),
                Float.parseFloat(list.get(5)));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.gargoylesoftware.htmlunit.html.IEConditionalCommentExpressionEvaluator.java

private static float parseVersion(final String s) {
    return Float.parseFloat(s);
}

From source file:com.adobe.acs.commons.images.transformers.impl.SharpenImageTransformerImpl.java

@Override
public final Layer transform(final Layer layer, final ValueMap properties) {

    if (properties == null || properties.isEmpty()) {
        log.warn("Transform [ {} ] requires parameters.", TYPE);
        return layer;
    }/*  w  w  w .ja v  a 2s .  c o m*/

    log.debug("Transforming with [ {} ]", TYPE);

    String unsharpenMask = StringUtils.trim(properties.get(KEY_UNSHARP_MASK, String.class));

    try {
        if (!unsharpenMask.isEmpty()) {
            String[] param = unsharpenMask.split(",");

            // Support is provided for amount and radius only.
            if (param.length == NUM_SHARPEN_PARAMS) {
                float amount = Float.parseFloat(param[0]);
                float radius = Float.parseFloat(param[1]);
                layer.sharpen(amount, radius);
            } else {
                log.warn("Transform [ {} ] requires 2 parameters.", TYPE);
            }
        }
    } catch (NumberFormatException exception) {
        log.warn("Transform [ {} ] requires floating type values.", TYPE);
        log.error("Exception occured while parsing string to float", exception);
    }
    return layer;
}

From source file:de.ingrid.iplug.opensearch.converter.RankingModifierFromPD.java

private void setAdditional(String additional) {
    if (additional != null) {
        this.additional = Float.parseFloat(additional);
    }
}

From source file:org.cellcore.code.engine.page.extractor.pkg.PKGPageDataExtractor.java

@Override
protected float getPrice(Document doc) {

    String price = ((Element) doc.getElementsByAttributeValueStarting("src", "./docs/illustrations/").get(0)
            .parent().parent().childNodes().get(5)).select("tbody").get(1).select("font").get(0).select("b")
                    .text();/*  w w  w . jav  a  2  s .  co  m*/
    if (price == null || price.equals("")) {
        price = doc.select("form").get(2).select("b").get(0).text();
    }
    price = cleanPriceString(price);
    return Float.parseFloat(price);
}

From source file:com.shoylpik.controller.AddProduct.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String SAVE_DIRECTORY = "menu_assets/ProductImage";
    String absolutePath = request.getServletContext().getRealPath("");
    String savePath = absolutePath + File.separator + SAVE_DIRECTORY;

    File imageSaveDirectory = new File(savePath);
    if (!imageSaveDirectory.exists()) {
        imageSaveDirectory.mkdir();//w w  w .jav a 2  s .  c o  m
    }
    System.out.println("absolutePath: " + absolutePath);
    System.out.println("SavePath: " + savePath);
    //        System.out.println("imageSaveDirectory.getAbsolutePath(): " + imageSaveDirectory.getAbsolutePath());
    String fileName = null;

    try {

        Part filePart = request.getPart("IPimage");
        String filename = getFilename(filePart);
        //            System.out.println("filename: " + filename);
        InputStream imageInputStream = filePart.getInputStream();
        byte[] bytes = IOUtils.toByteArray(imageInputStream);

        Product product = new Product();
        product.setProductId(Integer.parseInt(request.getParameter("IPID")));
        product.setProductName(request.getParameter("IPname"));
        product.setProductImageName(filename);
        product.setProductCategory(request.getParameter("IPcat"));
        product.setProductPrice(Float.parseFloat(request.getParameter("IPprice")));
        product.setProductQuantity(Integer.parseInt(request.getParameter("IPQuant")));

        ProductBean pBean = new ProductBean();
        pBean.addProduct(product);

        //            String fullImagePath = "menu_assets/images/"+filename;

        String fullImagePath = savePath + File.separator + filename;
        File file = new File(fullImagePath);
        //            System.out.println("fullImagePath : " + fullImagePath);
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(bytes);

    } catch (SQLException ex) {
        Logger.getLogger(AddProduct.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException | ServletException | NumberFormatException ex) {
        Logger.getLogger(AddProduct.class.getName()).log(Level.SEVERE, null, ex);
    }
    response.sendRedirect("AdministrationPage.jsp");
}

From source file:com.googlecode.dex2jar.tools.BaseCmd.java

protected Object convert(String value, Class<?> type) {
    if (type.equals(String.class)) {
        return value;
    }/* w  w  w.j a va 2  s  .com*/
    if (type.equals(int.class) || type.equals(Integer.class)) {
        return Integer.parseInt(value);
    }
    if (type.equals(long.class) || type.equals(Long.class)) {
        return Long.parseLong(value);
    }
    if (type.equals(float.class) || type.equals(Float.class)) {
        return Float.parseFloat(value);
    }
    if (type.equals(double.class) || type.equals(Double.class)) {
        return Double.parseDouble(value);
    }
    if (type.equals(boolean.class) || type.equals(Boolean.class)) {
        return Boolean.parseBoolean(value);
    }
    if (type.equals(File.class)) {
        return new File(value);
    }
    throw new RuntimeException("can't convert [" + value + "] to type " + type);
}

From source file:com.z.controllers.HomeController.java

@RequestMapping(value = "establecimientos/getByLocDep/{localidad}/{departamento}/{lat}/{lng}/{distanciaKM}/{regimen}", method = RequestMethod.GET)
public @ResponseBody List<Establecimientos> getEstbylocdep(@PathVariable("localidad") String localidad,
        @PathVariable("departamento") String departamento, @PathVariable("lat") String lat,
        @PathVariable("lng") String lng, @PathVariable("distanciaKM") double distanciaKM,
        @PathVariable("regimen") String regimen) {
    Criteria criteria = new CriteriaDistance(Float.parseFloat(lat), Float.parseFloat(lng), distanciaKM);
    if (regimen.equals("Todos")) {
        return criteria
                .meetCriteria(establecimientosDAO.listByLocalidadAndDepartamento(localidad, departamento));
    } else {/*from   w w  w  .j  a  va  2  s . c om*/
        return criteria.meetCriteria(
                establecimientosDAO.listByLocalidadAndDepartamento(localidad, departamento, regimen));
    }

}

From source file:com.cloudera.oryx.rdf.computation.CovtypeIT.java

private static List<Example> readCovtypeExamples() throws IOException {
    List<Example> allExamples = Lists.newArrayList();
    Pattern delimiter = Pattern.compile(",");
    File dataFile = new File(TEST_TEMP_INBOUND_DIR, "covtype.csv.gz");
    for (CharSequence line : new FileLineIterable(dataFile)) {
        String[] tokens = delimiter.split(line);
        Feature[] features = new Feature[54];
        for (int i = 0; i < 10; i++) {
            features[i] = NumericFeature.forValue(Float.parseFloat(tokens[i]));
        }//from w w w  .ja  v a2  s  .  c  o m
        for (int i = 10; i < 54; i++) {
            features[i] = CategoricalFeature.forValue(Integer.parseInt(tokens[i]));
        }
        Example trainingExample = new Example(CategoricalFeature.forValue(Integer.parseInt(tokens[54]) - 1),
                features);
        allExamples.add(trainingExample);
    }
    return allExamples;
}

From source file:io.ehdev.json.validation.pojo.validation.JsonValidationFloat.java

@Override
public boolean isEntryValid(String inputValue) {

    if (nullAcceptable && null == inputValue || StringUtils.equalsIgnoreCase("null", inputValue))
        return true;

    try {/*from   w w  w .j  a  v  a 2 s . c om*/
        Float value = Float.parseFloat(inputValue);
        return isEntryValid(value);
    } catch (Exception e) {
        return false;
    }

}