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 7792711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:16:14+00:00 2026-06-01T22:16:14+00:00

I am writing a Java program that inputs a test file, performs some modifications

  • 0

I am writing a Java program that inputs a test file, performs some modifications to the data, then writes it to a new file output.

The input text file looks like this…

url = http://184.154.145.114:8013/wlraac name = wlr samplerate = 44100 channels =2 format = S16le~
url = http://newstalk.fmstreams.com:8080 name = newstalk samplerate = 22050 channels = 1 format = S16le

The program needs to be able to change the samplerate to 44100, and the channels to 1, if they don’t already have these values. I would also remove the url and name pieces completely. After these changes, the new line needs to be written out to a different output text file.

So far, all my program can do is select a file and display the contents of the file to the user. Could someone please point me in the right direction for how my program should work
to achieve my required outcome.

As somebody asked here is what I have so far

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class reader2 {
public reader2() {
}
public static void main(String[] args) {
    reader(args);

}
public static void reader(String[] args) {

    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));

    chooser.setFileFilter(new javax.swing.filechooser.FileFilter() {
        public boolean accept(File f) {
            return f.getName().toLowerCase().endsWith(".txt")
            || f.isDirectory();
        }

        public String getDescription() {
            return "Text Documents (.txt)";
        }
    });

    int r = chooser.showOpenDialog(new JFrame());
    if (r == JFileChooser.APPROVE_OPTION) {
        String name = chooser.getSelectedFile().getName();
        String pathToFIle = chooser.getSelectedFile().getPath();
        System.out.println(name);
        try{
            BufferedReader reader = new BufferedReader( new FileReader( pathToFIle ) ); //Setup the reader

            while (reader.ready()) { //While there are content left to read
                String line = reader.readLine(); //Read the next line from the file
                String[] tokens = line.split( "url = " ); //Split the string at every @ character. Place the results in an array.

                for (String token : tokens){ //Iterate through all of the found results

                        //System.out.println(token);
                        System.out.println(token);
                    }

            }

            reader.close(); //Stop using the resource
        }catch (Exception e){//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }
    }
}

}
  • 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-01T22:16:15+00:00Added an answer on June 1, 2026 at 10:16 pm

    You will need to do something like this …

    1. Read the contents of the file, one line at a time
    2. Split the line up into the individual components, such as splitting it on the ‘space’ character
    3. Change the sample rate and channel values according to your question
    4. Write the line out to a file, and start again from step 1.

    If you give this a try, post some code on StackExchange with any problems and we’ll try to assist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a java program that requires some Data to run. The data
I'm writing a Java program that scrapes a web page for links and then
I am writing a java program that needs a file open dialog. The file
I'm writing a java program that goes out and searches twitter, finds certain instagram
I am writing a program that needs to run a java.jar server. I need
I am writing an access control program in Java that captures passwords using JPasswordField
I'm writing a multithreaded Java program where each thread potentially needs its standard output
I'm writing a program in Java where I read in data from an XML
I am writing a program that will change java code. It changes the next-line
I am writing a Java program that creates HTML code. What's the best/easiest possibility

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.