public boolean readRawData(RawData data) throws IOException {
    int readCount = 0;
    byte[] buff = data.getData();

    readCount = stream.read(buff, 0, RawData.BUFF_MAIN_SIZE);
    data.incSize(readCount);

    if (readCount < RawData.BUFF_MAIN_SIZE) {
      return false;
    }

    // need to read a few more bytes till the end of the line
    for (int i = RawData.BUFF_MAIN_SIZE;
        buff[i - 1] != -1 && buff[i - 1] != Constants.EOL_CODE_INT;
        i++) {
      buff[i] = (byte) stream.read();
      data.incSize(1);
    }

    return true;
  }
예제 #2
0
  public static void main(String[] args) throws FileNotFoundException, IOException {
    RawData input = new RawData();
    DataStorage dataStorage = new DataStorage();
    UIoutput output = new UIoutput(); // Open in truncate mode

    output.displayThis("-->> SETUP started");
    output.displayThis("-->> OPENED RawData file");
    output.displayThis("-->> OPENED Backup file");
    output.displayThis("-->> OPENED Log file\n");

    while (input.input1Country()) // loop through the end of the file
    {
      dataStorage.insert(input.getCountryCode(), input.getRestOfData());
      // store to interior storage, which is an array
    }

    output.displayThis("-->> CLOSED Log file");
    output.displayThis("-->> CLOSED Backup file");
    output.displayThis("-->> CLOSED RawData file");
    output.displayThis(
        "-->> SETUP finished" + " - inserted " + input.getN() + " countries into DataStorage\n");

    output.finishUp();
    dataStorage.finishUp();
    input.finishUp();
    System.out.printf("done");
  }