Exception in thread "main" java.lang.NumberFormatException: For input string: "through"

1

I need some help with this error and I have tried many things but I do not know what D can be: Here I leave the code to see if you can help me:

package Modulos;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class ConvoPulsos extends ApplicationFrame {

    public ConvoPulsos(String title, ArrayList data, int i, double desdeDominio, double hastaDominio, double desdeRango, double hastaRango) {
        super(title);

        JFreeChart xylineChart;
        ChartPanel chartPanel;
        XYPlot plot;
        XYLineAndShapeRenderer renderer;

        if (i == 0) {
            xylineChart = ChartFactory.createXYLineChart("", "Tiempo", "Amplitud", createDatasetGraf0(data), PlotOrientation.VERTICAL, true, true, false);
            chartPanel = new ChartPanel(xylineChart);
            chartPanel.setPreferredSize(new Dimension(550, 240));
            plot = xylineChart.getXYPlot();
            renderer = new XYLineAndShapeRenderer();
            renderer.setSeriesPaint(0, Color.BLUE);
            renderer.setSeriesStroke(0, new BasicStroke(1.0F));
            renderer.setSeriesShape(0, new Rectangle(0, 0));
            plot.setRenderer(renderer);
            plot.setBackgroundPaint(Color.WHITE);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.BLACK);
            plot.setDomainGridlinesVisible(true);
            plot.setDomainGridlinePaint(Color.BLACK);

            if ((desdeDominio != 0.0D) || (hastaDominio != 0.0D)) {
                plot.getDomainAxis().setRange(desdeDominio, hastaDominio);
            }

            if ((desdeRango != 0.0D) || (hastaRango != 0.0D)) {
                plot.getRangeAxis().setRange(desdeRango, hastaRango);
            }
            setContentPane(chartPanel);
        }
    }

    private XYDataset createDatasetGraf0(ArrayList data) {
        XYSeries dataPulso1 = new XYSeries("Pulso Rectangular Angosto");
        ArrayList table0 = new ArrayList();
        table0.addAll((Collection) data.get(0));
        double s = 0.0D;

        for (int h = 0; h < table0.size(); ++h) {
            dataPulso1.add(s, Double.parseDouble(table0.get(h).toString()));
            s += 0.00322580645D;
        }

        XYSeriesCollection dataplot = new XYSeriesCollection();
        dataplot.addSeries(dataPulso1);

        return dataplot;
    }

    public static ArrayList llamarOctave(String comando, int i)
            throws IOException, InterruptedException {
        List lineas = new ArrayList();
        Runtime run = Runtime.getRuntime();
        BufferedReader entrada = null;
        PrintWriter salida = null;
        ArrayList data = new ArrayList();

        try {
            Process octave = run.exec("octave");
            Iterator localIterator;
            String linea;
            String[] elementos;
            int j;

            try {
                Thread.sleep(3000L);
                entrada = new BufferedReader(new InputStreamReader(octave.getInputStream()));
                salida = new PrintWriter(new BufferedWriter(new OutputStreamWriter(octave.getOutputStream())));

                do {
                    System.out.println(entrada.readLine());
                } while (entrada.ready());

                System.out.println(comando);
                salida.println(comando);

                if (i == 0) {
                    System.out.println("sprintf('%f ', [ones(1,310) zeros(1,690)])");
                    salida.println("sprintf('%f ', p1=[ones(1,310) zeros(1,690)])");
                    salida.flush();

                    do {
                        lineas.add(entrada.readLine());
                    } while (entrada.ready());

                    for (localIterator = lineas.iterator(); localIterator.hasNext();) {
                        linea = (String) localIterator.next();
                        elementos = linea.split("\s+");
                        for (j = 2; j < elementos.length; ++j) {
                            data.add(elementos[j]);
                        }
                    }
                }
            } finally {
                if (entrada != null) {
                    entrada.close();
                }
                if (salida != null) {
                    salida.close();
                }

                octave.destroy();
            }
        } catch (IOException ex) {
            System.err.println("Error" + ex);
        }
        return data;
    }

    public static void main(String[] args) {
        try {
            ArrayList dataT = new ArrayList();
            ArrayList data = llamarOctave("t=[0:0.00322580645:3.22580645-0.00322580645]", 0);
            dataT.add(data.subList(0, 1000));
            ConvoPulsos test = new ConvoPulsos("Pulso Rectangular Angosto", dataT, 0, 0.0D, 0.0D, 0.0D, 0.0D);
            test.pack();
            RefineryUtilities.centerFrameOnScreen(test);
            test.setVisible(true);
        } catch (IOException | InterruptedException ex) {
        }
    }

The error call stack says:

  

Exception in thread "main" java.lang.NumberFormatException: For input   string: "through"
  at sun.misc.FloatingDecimal.readJavaFormatString (FloatingDecima l.java:2043)
  at sun.misc.FloatingDecimal.parseDouble (FloatingDecimal.java:11 0)
  at java.lang.Double.parseDouble (Double.java:538)
  at Modulos.ConvoPulsos.createDatasetGraf0 (ConvoPulsos.java:74)
  at Modulos.ConvoPulsos. (ConvoPulsos.java:40)
  at Modulos.ConvoPulsos.main (ConvoPulsos.java:151)
  C: \ Users \ Meily \ AppData \ Local \ NetBeans \ Cache \ 8.2 \ executor-sni ppets \ run.xml: 53: Java returned: 1 BUILD FAILED (total time: 5 seconds)

    
asked by Higor Mendoza 05.03.2017 в 02:54
source

0 answers