Question

I have the code

DebugDataOne1.txt

Somewhere over the rainbow.

DebugDataOne2.txt

There's no place like home.
Are you a good witch or a bad witch?

DebugThirteen1.java

import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
public class DebugThirteen1
{
public static void main(String[] args)
{

try
{
Path file1 =
Paths.get("C:\\Java\\Chapter.13\\\\DebugData1.txt");
Path file2 =
Paths.get("C:\\Java\\Chapter.13\\\\DebugData2.txt");// Please use the path of the file from where you want to access it.
BasicFileAttributes attr1 =
Files.readAttributes(file1, BasicFileAttributes.class);
System.out.println("File: " + file1.getFileName());
System.out.println("Creation time " + attr1.creationTime());
System.out.println("Last modified time " + attr1.lastModifiedTime());
System.out.println("Size " + attr1.size());
BasicFileAttributes attr2 =
Files.readAttributes(file2, BasicFileAttributes.class);
System.out.println("\nFile: " + file2.getFileName());
System.out.println("Creation time " + attr2.creationTime());
System.out.println("Last modified time " + attr2.lastModifiedTime());
System.out.println("Size " + attr2.size());
if(attr1.creationTime().compareTo(attr1.creationTime()) > 0)
System.out.println("\n" + file1.getFileName()+ " was created earlier");
else
System.out.println("\n" + file1.getFileName() + " was not created earlier");
if(attr1.size() > attr2.size())
System.out.println(file1.getFileName() + " is larger ");
else
System.out.println(file2.getFileName() + " is not larger");
}
catch(IOException e)
{
System.out.println("IO Exception "+e.getMessage());
}
}
}

I keep getting "IO Exception C:\Java\Chapter.13\\DebugData1.txt" in my terminal when I need File: DebugDataOne1.txt Creation time 2019-11-14T01:07:34.29741Z Last modified time 2019-11-14T01:07:37.4279777 Size 107 File

What am I doing wrong? Can somebody give me the right code?

0 0
Add a comment Improve this question Transcribed image text
Answer #1


import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;

public class DebugThirteen1 {
   public static void main(String[] args) {

       try {
           Path file1 = Paths.get("DebugData1.txt");
           Path file2 = Paths.get("DebugData2.txt");// Please use the path of the file from where you want to access
                                                       // it.
           BasicFileAttributes attr1 = Files.readAttributes(file1, BasicFileAttributes.class);
           System.out.println("File: " + file1.getFileName());
           System.out.println("Creation time " + attr1.creationTime());
           System.out.println("Last modified time " + attr1.lastModifiedTime());
           System.out.println("Size " + attr1.size());
           BasicFileAttributes attr2 = Files.readAttributes(file2, BasicFileAttributes.class);
           System.out.println("\nFile: " + file2.getFileName());
           System.out.println("Creation time " + attr2.creationTime());
           System.out.println("Last modified time " + attr2.lastModifiedTime());
           System.out.println("Size " + attr2.size());
           if (attr1.creationTime().compareTo(attr1.creationTime()) > 0)
               System.out.println("\n" + file1.getFileName() + " was created earlier");
           else
               System.out.println("\n" + file1.getFileName() + " was not created earlier");
           if (attr1.size() > attr2.size())
               System.out.println(file1.getFileName() + " is larger ");
           else
               System.out.println(file2.getFileName() + " is not larger");
       } catch (IOException e) {
           e.printStackTrace();
           System.out.println("IO Exception " + e.getMessage());
       }
   }
}

File: DebugDatal.txt Creation time 2019-11-15T01:25:18.131873Z Last modified time 2019-11-15T01:25:21.8040512 Size 19 File: D

Please use the code which I have shared and create these files at the same location where your running the program

Please create the DebugData1.txt file in your system where exactly your running this program

Please create the DebugData2.txt file in your system where exactly your running this program

Add a comment
Know the answer?
Add Answer to:
I have the code DebugDataOne1.txt Somewhere over the rainbow. DebugDataOne2.txt There's no place like home. Are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question I This question carries 20% of the marks for this assignment. You are asked to...

    Question I This question carries 20% of the marks for this assignment. You are asked to develop a set of bash shell script: Write a script that asks for the user's salary per month. If it is less or equals to 800, print a message saying that you need to get another job to increase your income, what you earn is the Minim living cost. If the user's salary is higher than 800 and below 2000, print a message telling...

  • Hello everyone. I have a bankers algorithm written in java that gets inputs from a .txt...

    Hello everyone. I have a bankers algorithm written in java that gets inputs from a .txt file. The file has 7 processes and 5 resources however, when the program runs, it doesn't sum the resource columns correctly. The program runs correctly for smaller matricies (4 processes, 3 resources), not sure what the issue is and have been looking over the code for awhile so maybe another set of eyes would help...thanks BankersAlgorithm.java /** * This program implements Bankers algorithm which...

  • JAVA: amortization table: Hi, I have built this code and in one of my methods: printDetailsToConsole...

    JAVA: amortization table: Hi, I have built this code and in one of my methods: printDetailsToConsole I would like it to print the first 3 payments and the last 3 payments if n is larger than 6 payments. Please help! Thank you!! //start of program import java.util.Scanner; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.lang.Math; //345678901234567890123456789012345678901234567890123456789012345678901234567890 /** * Write a description of class MortgageCalculator here. * * @author () * @version () */ public class LoanAmortization {    /* *...

  • I ONLY need question 2 part C AND D answered...it is in bold. Please do not...

    I ONLY need question 2 part C AND D answered...it is in bold. Please do not use hash sets or tables. In java, please implement the classes below. Each one needs to be created. Each class must be in separate file. The expected output is also in bold. I have also attached the driver for part 4 to help. 1. The Student class should be in the assignment package. a. There should be class variable for first and last names....

  • please help!!!! JAVA I done the project expect one part but I still give you all...

    please help!!!! JAVA I done the project expect one part but I still give you all the detail that you needed... and I will post my code please help me fix the CreateGrid() part in main and make GUI works    List Type Data Structures Overview : You will be implementing my version of a linked list. This is a linked list which has possible sublists descending from each node. These sublists are used to group together all nodes which...

  • How can I get started in this program for this DelivC?

    SpecificationStart with your Java program "prog340" which implements Deliverables A and B.This assignment is based on the definition of the Traveling Salesperson Problem (the TSP): Given a set of cities, you want to find the shortest route that visits every city and ends up back at the original starting city. For the purposes of this problem, every city will be directly reachable from every other city (think flying from city to city).Your goal is to use a non-genetic local search...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

  • starter code To write a program using the starter code which is TestLinkedList to see if...

    starter code To write a program using the starter code which is TestLinkedList to see if the LinkedList program has bugs. It will produce ether a pass or fail.More information is in the first two pictures. LinkedList.java /** * @author someone * * Implements a double-linked list with four errors */ public class LinkedList<E> { // The first and last nodes in the list private Node<E> head, tail; // Number of items stored in the list private int size; //...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

  • The following are screen grabs of the provided files Thanks so much for your help, and have a n...

    The following are screen grabs of the provided files Thanks so much for your help, and have a nice day! My Java Programming Teacher Gave me this for practice before the exam, butI can't get it to work, and I need a working version to discuss with my teacher ASAP, and I would like to sleep at some point before the exam. Please Help TEST QUESTION 5: Tamagotchi For this question, you will write a number of classes that you...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT