Question

Following is my java program that i need help with. Write a program that uses a...

Following is my java program that i need help with.

Write a program that uses a JavaFX GUI that allows a user to enter a directory (folder) and then displays the number of the files in the directory. The number of files in the directory should be determined recursively.

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

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

public class Main{

     public static void main(String args[]) throws IOException{

            System.out.println("enter the path to folder to search for file");

            Scanner sl=new Scanner(System.in);

           String folderPath=sl.next();

           File folder=new FIle(folderPath);

          if(folder.isDirectory()){

                  File[] listOfFiles=folder.listFiles();

                  if(listOfFiles.length < 1)

                        System.out.println("there is no file inside the folder");

                 else

                        System.out.println("List of files & Folder");

                for(File file:listOfFiles){

                       if(!file.isDirectory())

                            System.out.println(file.getCanonicalPath().toString());

                }

          }

        else

             System.out.println("there is no folder in given path :"+folderPath);

      }

}

Add a comment
Know the answer?
Add Answer to:
Following is my java program that i need help with. Write a program that uses a...
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 code for my java class !! Write a simple java program that uses loops. You...

    .Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...

  • I need help with the following. I need to write a program code in Java using...

    I need help with the following. I need to write a program code in Java using NetBeans. It is from How to Program Java book Chapter 2. This program should calculate the packing of Candles. First read: The number of candles The number of candles that fit in each case Then calculate and print: The number of full cases The number of candles left over (partial case) If this order is large (more than 5 full cases needed) An extra...

  • I need help to write a program in Java. If a moderately active person cuts their...

    I need help to write a program in Java. If a moderately active person cuts their calorie intake by 500 calories a day, they can typically lose about 4 pounds a month. Write a program that lets the user enter their starting weight, then creates and displays a table showing what their expected weight will be at the end of each month for the next 6 months if they stay on this diet.

  • Write the program in Java. Description: Write a program to calculate the total size of all...

    Write the program in Java. Description: Write a program to calculate the total size of all files in the current directory / folder and all sub-folders. Example: I have a directory with 1 file (size 150KB) and 2 subdirectories, each of which has 1 file (size 10KB each), then when I run this program on this directory, I expect the answer to be 170KB.

  • Need help on following Java GUI problem: Write a program that lets a user display and...

    Need help on following Java GUI problem: Write a program that lets a user display and modify pictures. Create a window. Add four buttons so that clicking a particular button will shift the image by a small amount in the north, south, east or west direction inside the window. Add a menu bar with two menus: File and Image. The File menu should contain an Open menu item that the user can select to display JPEG and PNG files from...

  • Write a javafx GUI program that uses a TextField to allow the user to enter a...

    Write a javafx GUI program that uses a TextField to allow the user to enter a string. When the user presses return, have the action handler for the TextField count the number of vowels (a, e, i, o, u, y) in the string. Use a switch statement for this rather that if statements. Write out the number of vowels in a Label. Case does not matter for the vowels.

  • Hi, Hi, I need someone to write a program in Phython 3.6, and please I will...

    Hi, Hi, I need someone to write a program in Phython 3.6, and please I will appreciate if the code is error free and indented correctly. The output would be preferable. thanks Write a GUI program that translates the Latin words to English. The window should have three buttons, one for each Latin word. When the user clicks a button, the program displays the English translation in a label. 3. Miles Per Gallon Calculator Write a GUI program that calculates...

  • JAVA PROGRAM. I need to write a program in java that will perform matrix addition and both matric...

    JAVA PROGRAM. I need to write a program in java that will perform matrix addition and both matrices have N rows and M columns, N>1 and M>1. The two matrices must be divided to four equal size sub-matrices and each sub-matrix has dimensions N/2 X M/2. I need to create four threads and each thread performs a sub-set of addition on one pair of the sub-matrices. I also need an extra thread for networking. The network part of this uses...

  • PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from...

    PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from tony gaddis starting out with java book. I have included the screenshot of the problems for reference. I need HELP implementing these two problems TOGETHER. There should be TWO class files. One which has TWO methods (one to implement problem 8, and one to implement problem 9). The second class should consist of the MAIN program with the MAIN method which calls those methods....

  • Write a java program that demonstrates recursion. This program can be in a java GUI frame...

    Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.) The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line. Demonstrate recursion with a function called LoadTruck() that takes a number of boxes...

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