Пример #1
0
 /**
  * Creates a new {@code FileContents} instance.
  *
  * @param text the contents of the file
  */
 public FileContents(FileText text) {
   fileName = text.getFile().toString();
   this.text = new FileText(text);
 }
Пример #2
0
 /**
  * Creates a new {@code FileContents} instance.
  *
  * @param filename name of the file
  * @param lines the contents of the file
  * @deprecated Use {@link #FileContents(FileText)} instead in order to preserve the original line
  *     breaks where possible.
  */
 @Deprecated
 public FileContents(String filename, String... lines) {
   fileName = filename;
   text = FileText.fromLines(new File(filename), Arrays.asList(lines));
 }
Пример #3
0
 /**
  * Gets the lines in the file.
  *
  * @return the lines in the file
  */
 public String[] getLines() {
   return text.toLinesArray();
 }
Пример #4
0
 /**
  * Get the line from text of the file.
  *
  * @param index index of the line
  * @return line from text of the file
  */
 public String getLine(int index) {
   return text.get(index);
 }
Пример #5
0
 /**
  * Get a single line. For internal use only, as getText().get(lineNo) is just as suitable for
  * external use and avoids method duplication.
  *
  * @param lineNo the number of the line to get
  * @return the corresponding line, without terminator
  * @throws IndexOutOfBoundsException if lineNo is invalid
  */
 private String line(int lineNo) {
   return text.get(lineNo);
 }