title: Only read the last character in a .txt file
body: <p>I am creating a program using processing that read txt file and send the result to the arduino.
  I can get it to send string and keep update, but as soon as I try to just send the last char it won't work... Can anyone help me with this? Basically I need to read the last char from a txt file and send it as char through serial to arduino, python or processing both will work!</p>
  <p>*Here is my code [ Processing ]</p>
  <pre><code>import processing.serial.*;
  import java.io.*;
  
  int mySwitch=0;
  int counter=0;
  String [] subtext;
  Serial myPort;
     
  void setup(){
     //Create a switch that will control the frequency of text file reads.
     //When mySwitch=1, the program is setup to read the text file.
     //This is turned off when mySwitch = 0
     mySwitch=1;
   
     //Open the serial port for communication with the Arduino
     //Make sure the COM port is correct
     myPort = new Serial(this, &quot;COM4&quot;, 9600);
     myPort.bufferUntil('\n');
  }
  
  void draw() {
     if (mySwitch&gt;0){
         /*The readData function can be found later in the code. This is the call to read a CSV file on the computer hard-drive. */
         readData(&quot;G:/Personal/control.txt&quot;);
   
         /*The following switch prevents continuous reading of the text file, until   we are ready to read the file again. */
         mySwitch=0;
     }
  
     /*Only send new data. This IF statement will allow new data to be sent to the arduino. */
     if(counter&lt;subtext.length){
         /* Write the next number to the Serial port and send it to the Arduino There will be a delay of half a second before the command is sent to turn the LED off : myPort.write('0'); */
         myPort.write(subtext[counter]);
         delay(500);
         myPort.write('0');
         delay(100);
  
         //Increment the counter so that the next number is sent to the arduino.
         counter++;
     } else{
         //If the text file has run out of numbers, then read the text file again in 5 seconds.
         delay(5000);
         mySwitch=1;
     }
  } 
  
  
  /* The following function will read from a CSV or TXT file */
  void readData(String myFileName){
   
   File file=new File(myFileName);
   BufferedReader br=null;
   
   try{
     br=new BufferedReader(new FileReader(file));
     String text=null;
   
     /* keep reading each line until you get to the end of the file */
   while((text=br.readLine())!=null){
     * Spilt each line up into bits and pieces using a comma as a separator */
  
     subtext = splitTokens(text,&quot;,&quot;);
   }
   }catch(FileNotFoundException e){
       e.printStackTrace();
   }catch(IOException e){
       e.printStackTrace();
   }finally{
       try {
          if (br != null){
             br.close();
          }
       } catch (IOException e) {
       e.printStackTrace();
     }
   }
  </code></pre>
  <p>And this is the data that i am dealing with</p>
  <blockquote>
  <p>[19:54:57] [Server thread/INFO]: [@] b</p>
  <p>[19:54:57] [Server thread/INFO]: [@] a</p>
  <p>[19:54:57] [Server thread/INFO]: [@] b</p>
  <p>[19:54:57] [Server thread/INFO]: [@] a</p>
  <p>[19:54:58] [Server thread/INFO]: [@] b</p>
  <p>[19:54:58] [Server thread/INFO]: [@] a</p>
  <p>[19:54:59] [Server thread/INFO]: [@] b</p>
  <p>[20:30:23] [Server thread/INFO]: [@] a</p>
  <p>[20:30:24] [Server thread/INFO]: [@] b</p>
  <p>[21:07:34] [Server thread/INFO]: [@] a</p>
  <p>[21:07:35] [Server thread/INFO]: [@] b</p>
  </blockquote>
  <ul>
  <li>The only value that I really care is a / b</li>
  <li>And this file will consistently update in this format</li>
  </ul>