Class AsciiReadSupport

java.lang.Object
cnuphys.magfield.converter.AsciiReadSupport

public class AsciiReadSupport extends Object
Support for simpe ASCII reads
Author:
heddle
  • Field Details

  • Constructor Details

    • AsciiReadSupport

      public AsciiReadSupport()
  • Method Details

    • nextNonComment

      public static String nextNonComment(BufferedReader bufferedReader)
      Get the next non comment line
      Parameters:
      bufferedReader - a buffered reader which should be linked to an ascii file
      Returns:
      the next non comment line (or null)
    • countNonCommentLines

      public static int countNonCommentLines(File file)
      Counts the number of non-comment lines in a file
      Parameters:
      file - the file in question
      Returns:
      the number of non-comment lines in the file
    • asciiFileToString

      public static String asciiFileToString(File file)
      Read an entire ascii file into a single string.
      Parameters:
      file - the file to read
      Returns:
      the string with the entire content of the file
    • countLines

      public static int countLines(File file)
      Count the lines in an ASCII file, without skipping comment
      Parameters:
      file - the file in question
      Returns:
      the number of lines in the file
    • nextTokens

      public static String[] nextTokens(BufferedReader bufferedReader)
      Get the next tokens from a buffered reader
      Parameters:
      bufferedReader - a buffered reader which should be linked to an ascii file
      Returns:
      the next set of white-space separated tokens.
    • tokens

      public static String[] tokens(String str, String delimiter)
      This method breaks a string into an array of tokens.
      Parameters:
      str - the string to decompose.
      delimiter - the delimiter
      Returns:
      an array of tokens
    • tokens

      public static String[] tokens(String str)
      This method breaks a string into an array of tokens.
      Parameters:
      str - the string to decompose.
      Returns:
      an array of tokens
    • skipLines

      public static void skipLines(int n, BufferedReader bufferedReader)
      Skip lines in an ascii file
      Parameters:
      n - the number of lines to skip
      bufferedReader - a buffered reader which should be linked to an ascii file