java - How to get the nextInt after the nextInt but retain the value -


my problem instead of fixed value of ivaluenext, want next value on excel sheet run, 125,152,...

import java.util.*; import java.io.*;  public class convertingdata {   public static void main (string [] args)   {     int i=1;     int j;     int ivalue;     int ivaluenext;     try      {       scanner ifsinput = new scanner(new file("input.csv"));       printstream ifsoutput = new printstream(new file("output.csv"));        while(ifsinput.hasnextline())       {          string tokens[] = ifsinput.nextline().split(",");         string repeat = tokens[tokens.length - 1];          string value = tokens[tokens.length - 3];         ivalue = integer.parseint( value );          (i=ivalue;i<=ivaluenext;i++)         {           system.out.println(i+","+repeat);           ifsoutput.println(i+","+repeat);         }       }       ifsinput.close();       ifsoutput.close();     }     catch (filenotfoundexception smsg)     {       system.out.println("file not found");     }   } } 

here part of csv file:

89,31,31 125,1,32 152,-12,20 155,1,21 181,6,27 287,1,28 290,1,29 308,-8,21 

if need "peek" @ next line while processing current line, first read lines in:

list<string> lines = new arraylist<string>(); while(ifsinput.hasnextline()) {     lines.add(ifsinput.nextline()); } ifsinput.close(); 

then process lines 1 one access next line:

for (int = 0; < lines.size(); i++) {     string line = lines.get(i);     string nextline = < lines.size() - 1 ? null : lines.get(i + 1);      string tokens[] = line.split(",");     string nexttokens[] = nextline.split(",");      // whatever logic need      ifsoutput.close(); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -