Perhaps I have misunderstood your problem, then. Serial.available() tells you how many bytes are waiting to be received. These would be bytes send from your Processing application to the Arduino which the sketch has not read yet.You can only have one thing writing to and reading from each end of the Serial connection, so if you have a Processing application accessing it, you must not use the Arduino serial monitor at the same time.
sketch_oct22b.cpp: In function 'void loop()':sketch_oct22b:54: error: expected `}' at end of input
float distance = analogRead(1);
//map float to an int int x = (int) distance;
data[counter] = String(serialDataIn);