File Chooser that returns array of filenames

I'd like to use File Chooser to create an array of file names to be used for further processing with a FileReader. Ideally files could be chosen individually, or by using a Control or Shift select as in the Windows environment. Is this possible, and if so, how?
Thanks...
(I know this may seem basic to some, but I'm just getting started here...)

fc.setMultiSelectionEnabled(true);
File[] files = fc.getSelectedFiles();

Similar Messages

  • File Chooser not returning full path

    I have a jsp page with a file chooser on it. Whenever a file is choosen and the form is submitted, it says "file not found". I figured out this was because the file chooser is not returning the full path name of the file, just the name itself. I'm calling it with this line.
    <td><input type="file" name="certFile" size="20" value="<%=certFile%>"><td/>
    It's weird because this line used to return the correct file name it's preceding path in this very same file. Does anyone know how to force it to get the full path, or why this used to work and now it dosn't. Was there posibly a default change for this in java?

    And is your server handling this "upload" by taking the file name from the request and using a java.io.File object to open that file? That's only a viable solution if the server and the client are the same computer, a rather pointless configuration.

  • Invoking stored procedure that returns array(oracle object type) as output

    Hi,
    We have stored procedures which returns arrays(oracle type) as an output, can anyone shed some light on how to map those arrays using JPA annotations? I tried using jdbcTypeName but i was getting wrong type or argument error, your help is very much appreciated. Below is the code snippet.
    JPA Class:
    import java.io.Serializable;
    import java.sql.Array;
    import java.util.List;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import org.eclipse.persistence.annotations.Direction;
    import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
    import org.eclipse.persistence.annotations.StoredProcedureParameter;
    * The persistent class for the MessagePublish database table.
    @Entity
    @NamedStoredProcedureQuery(name="GetTeamMembersDetails",
         procedureName="team_emp_maintenance_pkg.get_user_team_roles",
         resultClass=TeamMembersDetails.class,
         returnsResultSet=true,
         parameters={  
         @StoredProcedureParameter(queryParameter="userId",name="I_USER_ID",direction=Direction.IN,type=Long.class),
         @StoredProcedureParameter(queryParameter="employeeId",name="I_EMPLOYEEID",direction=Direction.IN,type=Long.class),
         @StoredProcedureParameter(queryParameter="TEAMMEMBERSDETAILSOT",name="O_TEAM_ROLES",direction=Direction.OUT,jdbcTypeName="OBJ_TEAM_ROLES"),
         @StoredProcedureParameter(queryParameter="debugMode",name="I_DEBUGMODE",direction=Direction.IN,type=Long.class)
    public class TeamMembersDetails implements Serializable {
         private static final long serialVersionUID = 1L;
    @Id
         private long userId;
         private List<TeamMembersDetailsOT> teamMembersDetailsOT;
         public void setTeamMembersDetailsOT(List<TeamMembersDetailsOT> teamMembersDetailsOT) {
              this.teamMembersDetailsOT = teamMembersDetailsOT;
         public List<TeamMembersDetailsOT> getTeamMembersDetailsOT() {
              return teamMembersDetailsOT;
    Procedure
    PROCEDURE get_user_team_roles (
    i_user_id IN ue_user.user_id%TYPE
    , o_team_roles OUT OBJ_TEAM_ROLES_ARRAY
    , i_debugmode IN NUMBER :=0)
    AS
    OBJ_TEAM_ROLES_ARRAY contains create or replace TYPE OBJ_TEAM_ROLES_ARRAY AS TABLE OF OBJ_TEAM_ROLES;
    TeamMembersDetailsOT contains the same attributes defined in the OBJ_TEAM_ROLES.

    A few things.
    You are not using a JDBC Array type in your procedure, you are using a PLSQL TABLE type. An Array type would be a VARRAY in Oracle. EclipseLink supports both VARRAY and TABLE types, but TABLE types are more complex as Oracle JDBC does not support them, they must be wrapped in a corresponding VARRAY type. I assume your OBJ_TEAM_ROLES is also not an OBJECT TYPE but a PLSQL RECORD type, this has the same issue.
    Your procedure does not return a result set, so "returnsResultSet=true" should be "returnsResultSet=false".
    In general I would recommend you change your stored procedure to just return a select from a table using an OUT CURSOR, that is the easiest way to return data from an Oracle stored procedure.
    If you must use the PLSQL types, then you will need to create wrapper VARRAY and OBJECT TYPEs. In EclipseLink you must use a PLSQLStoredProcedureCall to access these using the code API, there is not annotation support. Or you could create your own wrapper stored procedure that converts the PLSQL types to OBJECT TYPEs, and call the wrapper stored procedure.
    To map to Oracle VARRAY and OBJECT TYPEs the JDBC Array and Struct types are used, these are supported using EclipseLink ObjectRelationalDataTypeDescriptor and mappings. These must be defined through the code API, as there is currently no annotation support.
    I could not find any good examples or doc on this, your best source of example is the EclipseLink test cases in SVN,
    http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/plsql/
    http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/customsqlstoredprocedures/
    James : http://www.eclipselink.org

  • How Do I Call PL/SQL Stored Procedure That Returns String Array??

    I Have Problem Calling An Oracle(8i) Stored Procedure That Returns Array Type (Multi Rows)
    (As Good As String Array Type..)
    In This Fourm, I Can't Find Out Example Source.
    (Question is Exist.. But No Answer..)
    I Want An Example,, Because I'm A Beginner...
    (I Wonder...)
    If It Is Impossible, Please Told Me.. "Impossible"
    Then, I'll Give Up to Resolve This Way.....
    Please Help Me !!!
    Thanks in advance,

    // Try the following, I appologize that I have not compiled and run this ... but it is headed in the right direction
    import java.sql.*;
    class RunStoredProc
    public static void main(String args[])
    throws SQLException
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception ex)
    ex.printStackTrace();
    java.util.Properties props = new java.util.Properties();
    props.put("user", "********"); // you need to replace stars with db userid
    props.put("password", "********"); // you need to replace stars with userid db password
              // below replace machine.domain.com and DBNAME, and port address if different than 1521
    Connection conn =
    DriverManager.getConnection("jdbc:oracle:thin:@machine.domain.com:1521:DBNAME", props);
    // replace "Your Stored Procedure" with your stored procedure
    CallableStatement stmt = conn.prepareCall("Your Stored Procedure");
    ResultSet rset = stmt.execute();
    while(rset.next())
    System.out.println(rset.getString(1));

  • Need help adding a default file name in a file chooser of save dialog type

    I need to create a file chooser with save dialog type, how can I add a highlighted default file name into the File Name textfield? As in Microsoft Word, when you want to save a document, a default file name Doc1.doc will appear in the File name text field of the file chooser even when you change to other directories.

    For JRE 1.4.0 you can use this fix:
    public class FileChooserFix implements PropertyChangeListener {
      private String fileName;
       * @see PropertyChangeListener
      public void propertyChange(PropertyChangeEvent ev) {
        JFileChooser chooser = (JFileChooser)ev.getSource();
        if (JFileChooser.FILES_ONLY == chooser.getFileSelectionMode()) {
          if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            File selectedFile = (File)ev.getNewValue();
            if (selectedFile != null) {
              // remember fileName of selected file
              fileName = selectedFile.getName();
          if (fileName != null &&
              JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            // reset selected file
            File directory = (File)ev.getNewValue();
            chooser.setSelectedFile(new File(directory, fileName));
       * Convenience method to create a fixed file chooser.
       * @return      fixed file chooser
      public static JFileChooser create() {
        JFileChooser chooser = new JFileChooser();
        chooser.addPropertyChangeListener(new FileChooserFix());
        return chooser;

  • File Chooser in Flex

    I want to make a file chooser that can allow me to choose
    (Browse) where's the file that i want to upload. Anyone know how to
    create a file chooser with flex builder 2 ? I'm very appreciate for
    any answer.

    Here is an example that will make a file browser to choose
    either an image or mp3 file:
    private var upload_ref:FileReference;
    private function upload_media():void {
    var media_filter:FileFilter;
    var filter_array:Array = new Array();
    media_filter = new FileFilter("Images (*.jpg, *.jpeg, *.gif,
    *.png)", "*.jpg; *.jpeg; *.gif; *.png");
    filter_array.push(media_filter);
    media_filter = new FileFilter("Audio (*.mp3)", "*.mp3");
    filter_array.push(media_filter);
    upload_ref = new FileReference();
    upload_ref.browse(filter_array);
    upload_ref.addEventListener(Event.SELECT, file_selected);
    private function file_selected(evt:Event):void {
    if (upload_ref.name != null &&
    upload_ref.name.search(" ") == -1 &&
    upload_ref.name.search("'") == -1) {
    var sendVars:URLVariables = new URLVariables();
    sendVars.file_path = "/path_on_server_to_upload_to";
    var request:URLRequest = new URLRequest();
    request.url = "
    http://yourserver.com/upload_php_script.php";
    request.data = sendVars;
    request.method = URLRequestMethod.POST;
    upload_ref.addEventListener(Event.COMPLETE, completeUpload);
    upload_ref.upload(request);
    } else {
    Alert.show("File name can only include letters, numbers or
    underbars. No spaces.");
    Vygo

  • J file chooser

    Hello everybody,
    i was wondering if anybody can help me with this problem i am having. i am trying to create a jfilechooser that enco-operates the operating systems icons. basically if my program is running on window then it would know the icon to use for different files. i think you are suppose to use FileSystemView but i cant seem to get it to compile. basically i want the same file chooser that you get in softwares such as Microsoft word and so.
    thanks

    Swing uses a concept called a "Look and Feel".
    If you don't specify one, you get the Java default "Metal" look and feel. I'm pretty sure that it's the look and feel that determines what icons are used for files.
    If you want to use the windows look and feel, you would do perform a statement like this at the start of your code, before you display any frames or windows:
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    This will make all of your windows look like a Windows app (and it only works ON a Windows operating system).
    To automatically have your code set the Look and Feel relevant to the current platform, call:
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName() );
    I think there's a way to have one component (like just the FileChooser) use a specific look and feel, but it isn't really appropriate in general GUI terms, I think, to be inconsistent like that. Alternatively, you could create your own subclass of JFileChooser or FileChooserUI that duplicates the Windows one. For that, I'd recommend you start here:
    http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

  • JSF component (file-chooser, string feature is only needed).

    For a rapid prototype...
    I'm looking for a file-chooser that uses a JSF component, so I can get the string to the backing bean.
    I do not need to upload a file.
    Whats the easiest way to do this?
    More specifically, I want to be able to push on a button and have the file chooser dialog open, and then have the selection go to the input text component. I also need to bind it to the backing bean. I'm using JSF 2.0 and also have primefaces setup. I tried to mix in tomahawk, but things went crazy.
    Thanks,
    Robert

    EJP wrote:
    And the documentation ;-(((((((Yay, A nice rant thread! Don't get me started on documentation, show me one API or framework that has documentation that covers not only the beginner things but also the production scale features (properly, not just mentioning that the features exist).
    Of course it all makes sense, complete and helpful documentation halts the sales of books. for example, did you know that a book about Richfaces 4 has just hit the market?

  • BPEL build error when invoke an extrenal Web Service that returns an Array

    Hello,
    I built with JDeveloper a web service that returns an Array of Java Bean classes and I try to invoke this web service from a BPEL process. The wsdl file is automatically generated by the JDev. When I built the BPEl project I obtained the following error:
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAP-ENC:Array'. It was detected that 'SOAP-ENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAP-ENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'.
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAPENC:Array'. It was detected that 'SOAPENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/Top300FactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAPENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/Top300FactoryWS?WSDL'.
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAP-ENC:Array'. It was detected that 'SOAP-ENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAP-ENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'.
    Any hint? Thanks in advance!
    Regards,
    Marinel

    Hi,
    BPEL and BPEL PM do not have a good support for SOAPENC-Array: it would be very difficult to create such an array in BPEL or to receive it and manipulate it.
    The (unfortunately very intrusive) work around is to change the WSDL of the service to use a XML type defined using XML schema. This is all the more painful that JDev 9.0.4 does not have strong support for complex types.
    In general though, I would highly recommend this best practice:
    1) Start by define the WSDL contract first
    2) Then generate the server side skeleton to implement it
    3) Use BPEL as the client to this contract.
    By starting with the contract first, you make sure that 1) your interfaces are clean and coarse grained.
    2) things like java objects, sessions, etc to not leak through the interface (which would be the worst thing that could happen because it would closely link the client and the server.
    Sorry for not being more helpful. This will get radically cleaner in Oracle AS 10.1.3.
    Edwin

  • How do I uninstall programs and files, so that the old computer is returned to its original settings?

    Hi, I'm giving my aunt my old computer, I have already backed everything up on my new one. What's the best way to remove/uninstall programs and files so that its returned to its orignial settings?

    Prepare Your Mac for Sale
    Boot from the OS X Installer Disc One that came with the computer.  After the installer loads select your language and click on the Continue button.  When the menu bar appears select Disk Utility from the Utilities menu.  After DU loads select the startup volume from the left side list then click on the Erase tab.  Set the format type to Mac OS Extended (Journaled) then click on the Options button.  Select the one pass Zero Data option and click on the OK button.  Then click on the Erase button.
    Note: You can skip the Zero Data option if you are not concerned about removing sensitive personal data from the hard drive.  If you choose to skip this part of the process then it is possible for others to recover data from the hard drive.  The Zero Data procedure will prevent others from getting access to your personal information.
    This process will take 30 minutes to several hours depending upon the size of the hard drive.  After formatting has completed quit DU and return to the installer.  Now complete the OS X installation.  At the completion of the installation do not restart the computer.  Instead just shut it off.  The next user will be presented with the Setup Assistant when they turn on the computer just as it would if new out of the box.

  • Calling java class from PLSQL  that returns date/time a file was saved

    Does anybody know, is there a java class I can compile into Oracle DB, and call from PLSQL that returns me the date/time a file was saved.
    As far as I'm aware this cannot be achieved using UTL_FILE.
    Please advise
    Thanks
    Warren

    I found this thread from before that might be helpful
    how to connect to UNIX OS from oracle stored procedure

  • Is there any MBean that returns war file details of the current page/contex

    Hi,
    We are building some diagnostic tests which would run as MBeans, both config and runtime. These MBeans would be invoked when an incident/error occurred on a page. One of my diagnostic test is to "get the details of the war file, like war file name, file path etc..from the current web page/current context root... and then inspect for some entries in the configuration files inside that war file".
    Is there any weblogic MBean that gives me the details of the war file from the current web page / current context root?
    Appreciate your help.
    Thanks,
    Eshwar.
    Edited by: Eshwar Mekala on May 5, 2010 6:30 PM
    Edited by: Eshwar Mekala on May 10, 2010 3:52 PM

    There is information about the applications on the server via the ApplicationRuntimeMBean. I believe there is context root information for the app inside the ComponentRuntimeMBeans. So you could query the app runtime mbeans to find the matching the ApplicationRuntimeMBean. Then use that to find the matching AppDeploymentMBean which has the file location.
    There might also be something in the servlet API - I would ask in the webapp forum.

  • I need sorting VI that returns the sorted array element's positions in the unsorted array

    I need a VI that will very quickly (n log n) sort a 1D array of doubles.  This VI should not only output the sorted array, but for each of the sorted array elements, it should also output that sorted array element's position in the unsorted array.  So for example if the input array were:
    unsorted_array
    4.1
    2.3
    7.0
    5.6
    10.2
    Then the output arrays would be:
    sorted_array
    2.3
    4.1
    5.6
    7.0
    10.2
    indices_array
    1 (the value 2.3 is located at position 1 in the unsorted_array)
    0 (the value 4.1 is located at position 0 in the unsorted_array)
    3 (the value 5.6 is located at position 3 in the unsorted_array)
    2 (the value 7.0 is located at position 2 in the unsorted_array)
    4 (the value 10.2 is located at position 4 in the unsorted_array)
    This way I could generate the sorted_array using just the indices_array and the unsorted_array.  Has anyone written a nifty piece of code to do this?  I did some research on (n log n) sorting algorithms but most of them use recursion which I don't know how to do in LabVIEW.  It would also be nice to have an algorithm like this that could sort an array of strings.
    cheers,
    Richard

    Try something like the attached example (LabVIEW 7.0). I think it does what you need.
    (To understand the code, it is important to know that arrays of clusters are sorted by the first element in the cluster).
    Sort array itself sorts also array of strings, so you could just substitute, keeping the rest of the code the same.
    Sort array uses a variation of quicksort, so it should have about NlogN complexity.
    (If you think you only need the array of indices to later generate the sorted array, it does not make much sense to even do it. To get the indices, you need to sort the array anyway. You should just sort the plain array directly.
    Message Edited by altenbach on 07-13-2005 03:47 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortAndIndex.vi ‏26 KB

  • How to find if the user has selected one or many files using a file chooser

    I have a file chooser but want it to return either a file or file array depending on whether more than one file is selected but there doesn't seem to be any way to find out if that is the case or not. I want it to look something like:
                if(fileChooser.getSelectedFile().isDirectory()==true)
                    selectedFile=fileChooser.getCurrentDirectory();
                else if(fileChooser.multipleFilesSelected())
                    fileChooser.getSelectedFiles();//we have more than one file selected
                else   
                    fileChooser.getSelectedFile();    //if we have one file selected
                }am I going about dealing with this in the right way?

    OK, I scoured the API again and found I could avoid the problem altogether by using
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html#isMultiSelectionEnabled()
    and
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html#setFileSelectionMode(int)

  • Combining File Chooser and this MP3 class

    Hello all,
    I was curious if anyone could help me figure out how to get a file to actually load once it is used with this code.
    I'm unfamiliar with how it works and I was hoping for an explanation on it.
    I wasn't sure if I had to have the program recgonize that I would like to load a mp3 or if it just would load it automatically...
    Essentially, I want to be able to load a mp3 if I use the file chooser.
    I can try to clarify my question more if anyone should need it.
    Thank you
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class List extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton, saveButton;
        JTextArea log;
        JFileChooser fc;
        public List() {
            super(new BorderLayout());
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(5,20);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
           // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open a File...",
                                     createImageIcon("images/Open16.gif"));
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            saveButton = new JButton("Save a File...",
                                     createImageIcon("images/Save16.gif"));
            saveButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(saveButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would open the file.
                    log.append("Opening: " + file.getName() + "." + newline);
                } else {
                    log.append("Open command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            } else if (e.getSource() == saveButton) {
                int returnVal = fc.showSaveDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would save the file.
                    log.append("Saving: " + file.getName() + "." + newline);
                } else {
                    log.append("Save command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String path) {
            java.net.URL imgURL = List.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FileChooserDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new List();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }The mp3 class that I've been playing around with...
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import javazoom.jl.player.Player;
    public class MP3 {
        private String filename;
        private Player player;
        // constructor that takes the name of an MP3 file
        public MP3(String filename) {
            this.filename = filename;
        public void close() { if (player != null) player.close(); }
        // play the MP3 file to the sound card
        public void play() {
            try {
                FileInputStream fis = new FileInputStream(filename);
                BufferedInputStream bis = new BufferedInputStream(fis);
                player = new Player(bis);
            catch (Exception e) {
                System.out.println("Problem playing file " + filename);
                System.out.println(e);
            // run in new thread to play in background
            new Thread() {
                public void run() {
                    try { player.play(); }
                    catch (Exception e) { System.out.println(e); }
            }.start();
    // test client
        public static void main(String[] args) {
            String filename = "C:\\FP\\1.mp3";
            MP3 mp3 = new MP3(filename);
            mp3.play();
    }

    Thanks for the link
    I've been looking over the sections and still confused with the code.
    It's obvious that I have to do something with this portion of the code:
    public void actionPerformed(ActionEvent e) {
        //Handle open button action.
        if (e.getSource() == openButton) {
            int returnVal = fc.showOpenDialog(FileChooserDemo.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                //This is where a real application would open the file.
                log.append("Opening: " + file.getName() + "." + newline);
            } else {
                log.append("Open command cancelled by user." + newline);
    }I'm just not sure what.

Maybe you are looking for

  • How do i sync my ipod if my computer is not recognizing it when i connect it?

    i am trying to sync my ipod so i can delete all of my music on it. im using a new computer, not the one i downloaded all the music off of and stuff. when i plug in my ipod to the computer it makes a sound like its plugged in but it doesnt come up und

  • Match downpayment request with payments through F-53

    Hello, Our client makes downpayment request in F-47 and then makes payment (invoice-based) through F-53 or F110. How can we match the downpayment request with the payment made if it is not through F-48? Thanks in advance....

  • IMac won't recognize external microphone through 4-pin splitter

    I recently purchased a Turtle Beach Ear Force X12 headset with separate audio output/input jacks, so I planned ahead and purchased a "splitter" adapter to get it to work with my Late 2012 27" iMac's 3.5mm combo jack. According to different accounts,

  • BUG FOUND!! in Airport Disk programming

    I'm betting this is having a bigger issue then most poeple realize as it effects reconnecting to the Airport disk. Ok after lots of testing I've figured out a major bug in the Airport Disk Programming for Security. This has only been verified with th

  • Navigating to the text item with color

    hi all, i have 10 text_items in my form, i want that when i am in first text_item the color should change default to any color i want (take suppose yellow) then when i am going to second text_item then color should change to yellow like that it has t