code: public static LineString createLine(Geometry pointA, Geometry... optionalPoints) throws SQLException {
          if( pointA == null || optionalPoints.length > 0 && optionalPoints[0] == null) {
              return null;
          }
          if (pointA.getNumGeometries() == 1 && !atLeastTwoPoints(optionalPoints, countPoints(pointA))) {
              throw new SQLException("At least two points are required to make a line.");
          }
          List<Coordinate> coordinateList = new LinkedList<Coordinate>();
          addCoordinatesToList(pointA, coordinateList);
          for (Geometry optionalPoint : optionalPoints) {
              addCoordinatesToList(optionalPoint, coordinateList);
          }
          return ((Geometry) pointA).getFactory().createLineString(
                  coordinateList.toArray(new Coordinate[optionalPoints.length]));
      }
docs: Constructs a LINESTRING from the given POINTs or MULTIPOINTs
  
  @param pointA The first POINT or MULTIPOINT
  @param optionalPoints Optional POINTs or MULTIPOINTs
  @return The LINESTRING constructed from the given POINTs or MULTIPOINTs
  @throws SQLException