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
  • Need help debugging DebugThirteen1.Java Debug 13-1 DebugThirteen1.Java // Program describes two files // tells you which...

    Need help debugging DebugThirteen1.Java Debug 13-1 DebugThirteen1.Java // Program describes two files // tells you which one is newer and which one is larger import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class DebugThirteen1 {    public static void main(String[] args)    {       Path file1 =          Paths.get("/root/sandbox/DebugDataOne1");       Path file2 =          Paths.get("/root/sandbox/DebugDataOne2.txt");       try       {          BasicFileAttributes attr1 =             Files.readAttributes(file1, BasicFileAttributes.class);          System.out.println("File: " + file1getFileName());          System.out.println("Creation time " + attr1.creationTime());          System.out.println("Last modified time " + attr1lastModifiedTime());          System.out.println("Size " + attr1.size());          BasicFileAttributes attr2 =             Files.readAttributes(file2, BasicFileAttributes.class);          System.out.println("\nFile:...

  • The files provided in the code editor to the right contain syntax and/or logic errors. In...

    The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. Note: DebugDataOne1.txt and DebugDataOne2.txt do not need to be edited. They are used by the program. import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class DebugThirteen1 { public static void main(String[] args) { Path file1 = Paths.get("/root/sandbox/DebugDataOne1.txt"); // path to file DebugDataOne1.txt in...

  • 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 {    /* *...

  • Need to code the HeapSort Algorithm in java. Most of the code is already done just...

    Need to code the HeapSort Algorithm in java. Most of the code is already done just need to code the "heapify" part of the heapsort algorithm. My heapify code is in bold below called "sink", but when I run it it gives me 2 errors with the string compare part saying: WordCountHeap.java:61: error: cannot find symbol         if(l < k && String.Compare(pq[l], pq[n]) < 0)                           ^ symbol:   method Compare(String,String) location: class String Please fix the code and the "heapify"...

  • 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...

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