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

  • Home
  • SEARCH
  • 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 8683039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:56:07+00:00 2026-06-12T21:56:07+00:00

Only doing this because I am lazy. I just wrote a program to list

  • 0

Only doing this because I am lazy. I just wrote a program to list all my music into an excel file.

   import java.io.*;
   import org.apache.commons.io.FileUtils;

      public class NewClass {

        public static void main( String args[] ) 
        {
           File folder = new File("C:/Users/Public/Music/OldMusic");
           File[] listOfFiles = folder.listFiles();

            for (int i = 0; i < listOfFiles.length; i++) {
             try{
                 FileUtils.writeStringToFile(new File("test.xls"), listOfFiles[i].getName(), true);
                 BufferedWriter output;
                 output = new BufferedWriter(new FileWriter("test.xls", true));
                 output.newLine();
                 output.close();
             }
             catch (IOException e){
             }
          }
      }
     }

The code works fine, but at the end of every song there is .mp3 (i.e.: Metallica – Nothing Else Matters.mp3).

Is there a way just to have the Name of the song without the .mp3 at the end of it?

  • 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-06-12T21:56:08+00:00Added an answer on June 12, 2026 at 9:56 pm

    Use:

    String fname = listOfFiles[i].getName();
    fname.substring(0, fname.lastIndexOf("."))
    

    Instead of passing..

    listOfFiles[i].getName()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a few months ago I wrote this code because it was the only way
...before everything, I'm doing this out of curiosity only. Nothing real-world application here, but
I'm trying to achieve what this guy here is doing, only in PHP or
I'm doing some tests with new features of CSS3, but this combination only works
I am doing some input/output between a c++ and a python program (only floating
So I'm doing a lot of inserts which only I want to insert into
I'm doing a .NET unit as part of my studies. I've only just started,
I'm not exactly sure how to ask this because I am just learning OOP
I want to turn this: document.getElementById(associatedDisplayDiv).innerHTML += formatedResult; ... into jquery. I've tried doing
I have to implement a function to get headers only (without doing a GET

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.