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 6631445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:32:49+00:00 2026-05-25T22:32:49+00:00

This is actually my first post here. I wasn’t aware of this website, and

  • 0

This is actually my first post here. I wasn’t aware of this website, and I lurked around the questions and its certainly a place I want to keep coming to.

I’m in my Senior year for Computer Science but my programming skills are not that good, which makes me feel very disappointed in myself.

Anyways, I have a project due on Friday and I’ve been working on it since Saturday and I keep bashing my head making no progress.

I need to find the connected components in a graph and also read from a file an adjacency matrix.

I first tried in in python, using an igraph python library but I just kept having system errors. So after two days of trying to troubleshoot that, I gave up and moved onto Java where I’m trying to read the array.

Here is my current code that I have thus far, and I’m trying to google the best I can to find the answer. Right now I’m simply trying to read from a file and put the values into my 2d array. I commented out most of everything because I’m trying to simply figure out what I’m doing wrong.

package javaapplication1;
import java.io.*;

import java.util.Scanner;
import tio.*;


public class JavaApplication1 {


 public static void adjMatrix() throws FileNotFoundException, IOException{
   int i, j, n = 20;
   int[][]array = new int[n][n];
   String file = ("adjmatrix.txt");

   BufferedReader in = new BufferedReader(new FileReader(file));
   System.out.println(in.readLine());
   in.close();
   /*
   while(in.hasMoreElements()){
       for (i = 0; i < n; i++){
          for (j = 0; j < n; j++){
           array[i][j] = in.readInt();
          }    // end inner for     
        } // end outer for
   }

   //Print array
   System.out.println("Here is the matrix: ");
   for (i = 0; i < n; i++){
       for (j = 0; j < n; j++){
           System.out.print(array[i][j]);
       } // end innerfor
   } //end outerfor
   */





} // endclass



/**
 * @param args the command line arguments
 */
public static void main(String[] args)
    throws IOException{
    adjMatrix();
} // end main
} // end class

#

ERROR:
Exception in thread “main” java.io.FileNotFoundException: adjmatrix.txt

(The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:97)
at java.io.FileReader.(FileReader.java:58)
at javaapplication1.JavaApplication1.adjMatrix(JavaApplication1.java:26)
at javaapplication1.JavaApplication1.main(JavaApplication1.java:60)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

#

  • 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-05-25T22:32:50+00:00Added an answer on May 25, 2026 at 10:32 pm

    When you try to open a file without a direct path, Java will try to resolve it from the relative path. Here, since you simply put “adjmatrix.txt”, it assumes that the text file is living in the same directory as the class file with the main method that you execute (JavaApplication1 in package JavaApplication1). You should either move the text file into the package right next to the class file or add a more specific path name as Kevin stated.

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

Sidebar

Related Questions

Well, this is my first post here and really enjoying the site. I have
Okay this is my first post here so please forgive me if i mess
This is my first post here in StackOverflow. I am not a newbie to
I'm pretty new to the idea of recursion and this is actually my first
This is actually a two part question. First,does the HttpContext.Current correspond to the current
The first part of this question is actually a request for confirmation based on
I am actually stuck in merging the result of this two queries: first query:
I have two questions, actaully... First off, Why cant I do this: List<Object> object
it's my first post here :) I'm having some difficulties with dealing with urls
So I saw this post here and read it and it seems like bulk

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.