extractField(fieldArray, lineNum);
/** * Reads traces from a text file, one line at a time. * * @param fl a file name * @return <code>true</code> if successful, <code>false</code> otherwise. * @throws IOException if the there was any error reading the file * @throws FileNotFoundException if the file was not found */ private boolean readFile(final File fl) throws IOException, FileNotFoundException { boolean success = false; BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(fl))); // read one line at the time int line = 1; String readLine = null; while (reader.ready() && (readLine = reader.readLine()) != null) { parseValue(readLine, line); line++; } reader.close(); success = true; } finally { if (reader != null) { reader.close(); } } return success; }
/** * Reads job information from a trace file and generates the respective cloudlets. * * @return the list of cloudlets read from the file; <code>null</code> in case of failure. * @see #file */ @Override public ArrayList<Cloudlet> generateWorkload() { if (jobs == null) { jobs = new ArrayList<Cloudlet>(); // create a temp array fieldArray = new String[MAX_FIELD]; try { /*@todo It would be implemented using specific classes to avoid using ifs. If a new format is included, the code has to be changed to include another if*/ if (file.getName().endsWith(".gz")) { readGZIPFile(file); } else if (file.getName().endsWith(".zip")) { readZipFile(file); } else { readFile(file); } } catch (final FileNotFoundException e) { } catch (final IOException e) { } } return jobs; }
numProc = 1; createJob(id, submitTime, runTime, numProc, reqRunTime, userID, groupID); } catch (final Exception e) {
/** * Reads traces from a gzip file, one line at a time. * * @param fl a gzip file name * @return <code>true</code> if successful; <code>false</code> otherwise. * @throws IOException if the there was any error reading the file * @throws FileNotFoundException if the file was not found */ private boolean readGZIPFile(final File fl) throws IOException, FileNotFoundException { boolean success = false; BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(fl)))); // read one line at the time int line = 1; String readLine = null; while (reader.ready() && (readLine = reader.readLine()) != null) { parseValue(readLine, line); line++; } reader.close(); success = true; } finally { if (reader != null) { reader.close(); } } return success; }
String readLine = null; while (reader.ready() && (readLine = reader.readLine()) != null) { parseValue(readLine, line); line++;