Skip to content

Commit

Permalink
working on file io
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Langensiepen committed May 19, 2013
1 parent fde4cda commit 8edab40
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
12 changes: 2 additions & 10 deletions MattJobCreator.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package Scheduler;

/**
* <p>Title: MattJobCreator</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author Matt Evett
* @version 1.0
*/

class MattJobCreator extends JobCreator {
public MattJobCreator(SystemSimulator s) {
super(s);
}

public Job createJob(String description, SystemSimulator s, String name) {
// Return a Job or subtype of Job for eventual execution.
System.out.println("Creating a new job at time "+System.currentTimeMillis());
System.out.println("Creating a new job at time " + System.currentTimeMillis());
return new MattJob(description, mySystem, name);
}
}
56 changes: 28 additions & 28 deletions RunScheduler.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
package Scheduler;

import java.io.File;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;

public class RunScheduler {
public static void main(String[] args) {
public static void main(String[] args) throws FileNotFoundException {
Thread thisThread = Thread.currentThread();
thisThread.setPriority(Thread.MAX_PRIORITY);
SystemSimulator os = new SystemSimulator();
ArrayList jobs = new ArrayList();

Object in;
// Here you need to parse the input file, scheduleInput.txt, to create the
// jobs ArrayList.
// For testing purposes, though, I'll just hardwire a three-value list. The
// RunScheduler that you submit should NOT have the following three lines.
ListManager reader = new ListManager();
ArrayList<Integer> readData = reader.readData();
String temp = "";
for(int i=0; i<readData.size(); i++) {
}

jobs.add("1 0 300");
jobs.add("2 100 300");
jobs.add("3 300 300");
// jobs.add("1 0 300");
// jobs.add("2 100 300");
// jobs.add("3 300 300");

JobCreator sinecure = new JobCreator(os);
Submittor sub = new Submittor(jobs, os, sinecure);
Expand All @@ -35,27 +36,26 @@ public static void main(String[] args) {
// As the driver exits, os has the highest priority, so should get the
// cpu....
}

}

class FileStreamsReadnWrite {
public static void main(String[] args) {
class ListManager {
//adapted from http://csis.pace.edu/~wolf/cs121/TestFiles2.htm
private ArrayList<Integer> dataList = new ArrayList<Integer>();
public ArrayList<Integer> readData() {
try {
File stockInputFile = new File("/.txt");
File StockOutputFile = new File("/.txt");

FileInputStream fis = new FileInputStream(stockInputFile);
FileOutputStream fos = new FileOutputStream(StockOutputFile);
int count;

while ((count = fis.read()) != -1) {
fos.write(count);
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream("scheduleInput.txt")));
StreamTokenizer tokens = new StreamTokenizer(input);
int next = tokens.nextToken();
while (next != tokens.TT_EOF) {
double nval = tokens.nval;
dataList.add((int) nval);
next = tokens.nextToken();
}
fis.close();
fos.close();
} catch (FileNotFoundException e) {
System.err.println("FileStreamsReadnWrite: " + e);
input.close();
} catch (IOException e) {
System.err.println("FileStreamsReadnWrite: " + e);
} catch (NumberFormatException e) {
}
return dataList;
}
}
}

0 comments on commit 8edab40

Please sign in to comment.