Programming Exercise 13-3
Instructions
Write an application that displays the sizes of the files lyric1.txt and lyric2.txt in bytes as well as the ratio of their sizes to each other.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FileSizeComparison.java
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
public class FileSizeComparison {
public static void main(String[] args) {
Path textFile = Paths.get("/root/sandbox/lyric1.txt");
Path wordFile = Paths.get("/root/sandbox/lyric2.txt");
// Write your code here
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lyric1.txt
I hope you had the time of your life.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lyric2.txt
Would you lie with me and just forget the world?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
public class FileSizeComparision {
public static void main(String[] args) throws Exception {
Path textFile = Paths.get("/root/sandbox/lyric1.txt");
Path wordFile = Paths.get("/root/sandbox/lyric2.txt");
BasicFileAttributes b1= Files.readAttributes(textFile,
BasicFileAttributes.class);
BasicFileAttributes b2= Files.readAttributes(wordFile,
BasicFileAttributes.class);
long size1=b1.size();
long size2=b1.size();
System.out.println(textFile.getFileName()+" : "+size1+"
bytes");
System.out.println(wordFile.getFileName()+" : "+size2+"
bytes");
System.out.println(textFile.getFileName()+" is ");
// Write your code here
}
}

Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Programming Exercise 13-3 Instructions Write an application that displays the sizes of the files lyric1.txt and...
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 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...
This is a JAVA language 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: DebugData2.txt does not need to be edited. It is used by the program. DebugData2.txt 435-9845 239-9845 981-9883 384-5656 875-3784 874-8120 DebugThirteen2.java // Program reads in a file of phone numbers without area codes // inserts "(312)...
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...
Write a Java application that displays the following ClickMe When the user clicks on "Click Me" button, the text, "l am clicked" is displayed. ClickMe am clicked import java.awt.*; import java.awt.event.*; public class OneButton extends JFrame implements ActionListener private JButton button; private JTextField field; public static void main(String args)( OneButton myCoolButton new OneButton0;
Write a JavaFX application that displays 10,000 very small circles (radius of 1 pixel) in random locations within the visible area. Fill the dots on the left half of the scene red and the dots on the right half of the scene green. Use the getWidth method of the scene to help determine the halfway point. This is what I have so far: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.shape.Circle; import javafx.scene.paint.Color; import javafx.stage.Stage; import java.util.Random; import javafx.scene.Group; public class Class615...
***Please keep given code intact*** Write a JavaFX application that displays a label and a Button to a frame in the FXBookQuote2 program. When the user clicks the button, display the title of the book that contains the opening sentence or two from your favorite book in the label. FXBookQuote2.java /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the...
//No JPanel please: Write a javafx application that displays an image and //plays a sound effect with each mouse click. Rotate through four images and //five sound effects, so the image/sound effect pairing is different each time. //What my problem is on is actually getting the pictures to switch. The x variable //works perfect for the sound change but I am unsure what to do with y for the //image change. Also I dont know if I should put this...
I have the files set up in the write place. I am just confused
on how to use some of the desire methods to execute this code.
// Copy text file and insert line numbers Create a NetBeans project named AddLineNumbers following the instructions provided in the Starting a NetBeans Project instructions in the Programming Exercises/Projects Menu on Blackboard. After you have created your NetBeans project AddLineNumbers and before you attempt to execute your application download and/or copy the text...
CENGAGE MINDTAP gramming Exercise 3-8 PaintCalculator.java Instructions Assume that a gallon of paint covers about 350 square feet of wall space. Create an application with a main() method that prompts the user for the length, width, and height of a rectangular room. Pass these three values to a method that does the following: 1 import java.util.Scanner; 2 public class PaintCalculator { 3 public static void main(String args[]) { // Write your code here public static double computeArea double length, double...