Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:59:33+00:00 2026-06-10T06:59:33+00:00

I have downloaded the SSJ library, a Java library for stochastic simulation. One of

  • 0

I have downloaded the SSJ library, a Java library for stochastic simulation. One of the files needs to open a *.dat file.

I am trying to run the file as downloaded, and the dat file is also there but I get the FileNotFoundException everytime.

Here’s the source code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
import umontreal.iro.lecuyer.randvar.ExponentialGen;
import umontreal.iro.lecuyer.rng.MRG32k3a;
import umontreal.iro.lecuyer.rng.RandomStream;
import umontreal.iro.lecuyer.simevents.Event;
import umontreal.iro.lecuyer.simevents.Sim;
import umontreal.iro.lecuyer.simprocs.Resource;
import umontreal.iro.lecuyer.simprocs.SimProcess;
import umontreal.iro.lecuyer.stat.Tally;

public final class Jobshop {
   int nbMachTypes;       // Number of machine types M.
   int nbTaskTypes;       // Number of task types N.
   double warmupTime;     // Warmup time T_0.
   double horizonTime;    // Horizon length T.
   boolean warmupDone;    // Becomes true when warmup time is over.
   Resource[] machType;   // The machines groups as resources.
   Jobshop.TaskType[] taskType;   // The task types.
   RandomStream streamArr = new MRG32k3a(); // Stream for arrivals.
   BufferedReader input;

   public Jobshop() throws IOException { readData(); }

   // Reads data file, and creates machine types and task types.
   void readData() throws IOException {
 // input = new BufferedReader (new FileReader ("Jobshop.dat"));
  input = new BufferedReader (new FileReader ("JobShop.dat"));
  StringTokenizer line = new StringTokenizer (input.readLine());
  warmupTime = Double.parseDouble (line.nextToken());
  line = new StringTokenizer (input.readLine());
  horizonTime = Double.parseDouble (line.nextToken());
  line = new StringTokenizer (input.readLine());
  nbMachTypes = Integer.parseInt (line.nextToken());
  nbTaskTypes = Integer.parseInt (line.nextToken());
  machType = new Resource[nbMachTypes];
  for (int m=0; m < nbMachTypes; m++) {
     line = new StringTokenizer (input.readLine());
     String name = line.nextToken();
     int nb = Integer.parseInt (line.nextToken());
     machType[m] = new Resource (nb, name);
  }
  taskType = new Jobshop.TaskType[nbTaskTypes];
  for (int n=0; n < nbTaskTypes; n++)
     taskType[n] = new Jobshop.TaskType();
  input.close();
}


class TaskType {
  public String     name;        // Task name.
  public double     arrivalRate; // Arrival rate.
  public int        nbOper;      // Number of operations.
  public Resource[] machOper;    // Machines where operations occur.
  public double[]   lengthOper;  // Durations of operations.
  public Tally      statSojourn; // Stats on sojourn times.

  // Reads data for new task type and creates data structures.
  TaskType() throws IOException {
     StringTokenizer line = new StringTokenizer (input.readLine());
     statSojourn = new Tally (name = line.nextToken()); 
     arrivalRate = Double.parseDouble (line.nextToken());
     nbOper = Integer.parseInt (line.nextToken());
     machOper = new Resource[nbOper];
     lengthOper = new double[nbOper];
     for (int i = 0; i < nbOper; i++) {
        int p = Integer.parseInt (line.nextToken());
        machOper[i] = machType[p-1];
        lengthOper[i] = Double.parseDouble (line.nextToken());
     }
  }

  // Performs the operations of this task (to be called by a process).
  public void performTask (SimProcess p) {
     double arrivalTime = Sim.time();
     for (int i=0; i < nbOper; i++) {
        machOper[i].request (1); p.delay (lengthOper[i]);
        machOper[i].release (1);
     }
     if (warmupDone) statSojourn.add (Sim.time() - arrivalTime);
  }
}

public class Task extends SimProcess {
  Jobshop.TaskType type;

  Task (Jobshop.TaskType type) { this.type = type; }

  public void actions() { 
  // First schedules next task of this type, then executes task.
     new Jobshop.Task (type).schedule (ExponentialGen.nextDouble
           (streamArr, type.arrivalRate));
     type.performTask (this);
  }
}

Event endWarmup = new Event() {
  public void actions() {
     for (int m=0; m < nbMachTypes; m++)
        machType[m].setStatCollecting (true);
     warmupDone = true;
  }
};

Event endOfSim = new Event() {
    @Override
  public void actions() { Sim.stop(); }
};

public void simulateOneRun() {
  SimProcess.init();
  endOfSim.schedule (horizonTime);
  endWarmup.schedule (warmupTime);
  warmupDone = false;
  for (int n = 0; n < nbTaskTypes; n++) {
     new Jobshop.Task (taskType[n]).schedule (ExponentialGen.nextDouble 
        (streamArr, taskType[n].arrivalRate));
  }
  Sim.start();
}

public void printReportOneRun() {
  for (int m=0; m < nbMachTypes; m++) 
     System.out.println (machType[m].report());
  for (int n=0; n < nbTaskTypes; n++) 
     System.out.println (taskType[n].statSojourn.report());
}

static public void main (String[] args) throws IOException { 
  Jobshop shop = new Jobshop();
  shop.simulateOneRun();
  shop.printReportOneRun();
}
}

and here’s the output:

 Exception in thread "main" java.io.FileNotFoundException: JobShop.dat (O sistema não conseguiu localizar o ficheiro especificado)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at java.io.FileReader.<init>(FileReader.java:58)
at Jobshop.readData(Jobshop.java:31)
at Jobshop.<init>(Jobshop.java:26)
at Jobshop.main(Jobshop.java:133)
Java Result: 1

Any clue on how to fix it?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:59:35+00:00Added an answer on June 10, 2026 at 6:59 am

    The way the file is referred, it expects to find the file in the location where you run the application from. It seems like it cannot find it there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have downloaded a Java 3d-1_5_1-macosx.zip. I am trying unzip the file. The file
I have downloaded TableView sample code '4_TableViewCellSubviews' from internet. I am trying to run
I have downloaded the latest version of SFML (a library) which includes source files,
I have downloaded the Layar401.apk file from web and trying to install it into
I have downloaded an .osm file from open street map and I want to
I have downloaded and run the Java sound demo available on http://java.sun.com/ . When
I have downloaded ffmpeg lib file and complied it for armv7. I added ffmpeg
I have downloaded follwing code from one of Google Codes but problem is in
I have downloaded ajax control toolkit (newest) and trying out fileupload. It's really good
I have downloaded a file WINDOWS POWERSHELL that has an .msu extension how do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.