Begin document

@param isArray True the document is an array structure, false is an object structure
@return This structured writer
@throws IOException Something went wrong writing
545814
public JsonWriter beginDocument(boolean isArray) throws IOException {
      this.isArray = isArray;
      if (isArray) {
         writer.beginArray();
      } else {
         writer.beginObject();
      }
      writeStack.add(JsonTokenType.BEGIN_DOCUMENT);
      return this;
   }
612709
public boolean inArray() {
      return writeStack.peek() == JsonTokenType.BEGIN_ARRAY || (writeStack.peek() == JsonTokenType.BEGIN_DOCUMENT && isArray);
   }
374260
public static String[] subarrayOf
            (final String[] array,
             final int start,
             final int end)
        {
        final int subarraySize = end - start;
        final String[] subarray = new String[subarraySize];

        for (int i = 0; i < subarraySize; ++i)
            {
            subarray[i] = array[i + start];
            }

        return (subarray);
        }
1334737
public void beginArray() throws IOException {
    int p = peeked;
    if (p == PEEKED_NONE) {
      p = doPeek();
    }
    if (p == PEEKED_BEGIN_ARRAY) {
      push(JsonScope.EMPTY_ARRAY);
      pathIndices[stackSize - 1] = 0;
      peeked = PEEKED_NONE;
    } else {
      throw new IllegalStateException("Expected BEGIN_ARRAY but was " + peek()
          + " at line " + getLineNumber() + " column " + getColumnNumber() + " path " + getPath());
    }
  }
1265695
public Type getType(Type baseType, boolean isArray, List<Type> typeParams) {
    boolean isGeneric = typeParams != null && !typeParams.isEmpty();
    if (!isArray && !isGeneric) {
      // Simple type.
      return baseType;
    } else if (isArray && !isGeneric) {
      // Array type, not generic.
      ClassSymbol arraySymbol = getSymtab().arrayClass;
      return new ArrayType(baseType, arraySymbol);
    } else if (!isArray && isGeneric) {
      // Generic type, not array.
      com.sun.tools.javac.util.List<Type> typeParamsCopy =
          com.sun.tools.javac.util.List.from(typeParams);
      return new ClassType(Type.noType, typeParamsCopy, baseType.tsym);
    } else {
      throw new IllegalArgumentException("Unsupported arguments to getType");
    }
  }
555736
private boolean goToNextStartPosition() throws IOException {
    int basicStartPosition;
    int basicEndPosition;
    if (docId == -1 || docId == NO_MORE_DOCS) {
      throw new IOException("no document");
    } else {
      while ((basicStartPosition = subSpans
          .nextStartPosition()) != NO_MORE_POSITIONS) {
        basicEndPosition = subSpans.endPosition();
        startPosition = Math.max(minPosition,
            (basicStartPosition - query.maximumLeft));
        endPosition = Math.min(maxPosition + 1,
            (basicEndPosition + query.maximumRight));
        if (startPosition <= (basicStartPosition - query.minimumLeft)
            && endPosition >= (basicEndPosition + query.minimumRight)) {
          return true;
        }
      }
      return false;
    }
  }
950144
private static void arrayToWriter(Object array, JsonWriter writer) throws IOException {
    writer.beginArray();
    for (int i = 0, size = Array.getLength(array); i < size; i++) {
      writeValue(Array.get(array, i), writer);
    }
    writer.endArray();
  }
560518
public boolean inObject() {
      return writeStack.peek() == JsonTokenType.BEGIN_OBJECT || (writeStack.peek() == JsonTokenType.BEGIN_DOCUMENT && !isArray);
   }
392924
public JSONWriter arrayBegin() throws IOException {
        beforeValue();

        writer.write(JSON.LSQUARE);
        stack.push(state);
        state = new State(ARRAY);
        return this;
    }
1291905
public void beginArray() throws IOException {
    int p = peeked;
    if (p == PEEKED_NONE) {
      p = doPeek();
    }
    if (p == PEEKED_BEGIN_ARRAY) {
      push(JsonScope.EMPTY_ARRAY);
      pathIndices[stackSize - 1] = 0;
      peeked = PEEKED_NONE;
    } else {
      throw new IllegalStateException("Expected BEGIN_ARRAY but was " + peek() + locationString());
    }
  }
286484
public void endDocument() throws IOException {
      checkAndPop(JsonTokenType.BEGIN_DOCUMENT);
      if (isArray) {
         writer.endArray();
      } else {
         writer.endObject();
      }
   }
1356408
public <T> File writeLines(Collection<T> list, boolean isAppend) throws IORuntimeException {
		return writeLines(list, null, isAppend);
	}
1083615
protected JsonWriter value(@NonNull Object[] array) throws IOException {
      return value(Arrays.asList(array));
   }
1018541
public static final boolean startsWith(char[] array, char[] toBeFound)
	{
		int i = toBeFound.length;
		if (array.length < i)
		{
			return false;
		}
		while (--i >= 0)
		{
			if (toBeFound[i] != array[i])
			{
				return false;
			}
		}
		return true;
	}
466510
private boolean init() throws IOException, CompoundNotFoundException {

		BufferedReader br = new BufferedReader(new FileReader(file));
		br.skip(sequenceStartIndex);
		String sequence = sequenceParser.getSequence(br, sequenceLength);
		setContents(sequence);
		br.close(); // close file to prevent too many being open

		return true;
	}
1141126
public JBBPFieldStruct parse(final byte[] array) throws IOException {
    JBBPUtils.assertNotNull(array, "Array must not be null");
    return this.parse(new ByteArrayInputStream(array), null, null);
  }
445398
public File write(byte[] data, int off, int len, boolean isAppend) throws IORuntimeException {
		FileOutputStream out = null;
		try {
			out = new FileOutputStream(FileUtil.touch(file), isAppend);
			out.write(data, off, len);
			out.flush();
		}catch(IOException e){
			throw new IORuntimeException(e);
		} finally {
			IoUtil.close(out);
		}
		return file;
	}