English 中文(简体)
java.io.FileNotFoundExceptionis , 出于不明原因被推翻
原标题:java.io.FileNotFoundExceptionis thrown for unknown reason

问题! 我把整个文件夹从桌面上调来:出于某种原因,它正在工作。

I ve a very weird scenario.
I try to run my partner s version which is fully working without any exceptions in his computer- it is the same project..
Any ideas?
Relevant code added..

public class DJ implements Runnable
{
    private static final int k_SoundLoop = 500;
    private static final int k_NumberOfSong = 2;
    private static final int k_CairoTrainSong = 0;
    private static final int k_MachineSong = 1;


    private ArrayList<Clip> m_Records = new ArrayList<Clip>();
    private int m_CurrentRecored = 0;
    private Thread m_MusicThread = null;
    private AppletContext m_AppletContext;
    //java.net.URL m_CodeBase;
    //AppletContext ac;

    public DJ() 
    {
        try 
        {
            createClip(getClass().getResource("/Music/train.au"));
            createClip(getClass().getResource("/Music/machine.au"));
        }
        catch (Exception ex)
        {
            Logger.getLogger(DJ.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void createClip(URL i_SoundFileURL) throws Exception
    {

        File soundFile = new File(i_SoundFileURL.getFile());
        AudioInputStream sound = AudioSystem.getAudioInputStream(soundFile);
        // load the sound into memory (a Clip)
        DataLine.Info info = new DataLine.Info(Clip.class, sound.getFormat());
        Clip clip = (Clip) AudioSystem.getLine(info);
        clip.open(sound);
        m_Records.add(clip);
    }


    public void play()
    {
        m_Records.get(m_CurrentRecored).loop(k_SoundLoop);
    }


    public void play(int i_RecoredNumber)
    {
        stopCurrentClipIfNeeded();
        m_CurrentRecored = i_RecoredNumber;
        m_Records.get(m_CurrentRecored).start();
    }

    public void stop()
    {
        stopCurrentClipIfNeeded();
        m_CurrentRecored = 0;
    }

    public void stop(int i_RecordNumber)
    {
        m_Records.get(i_RecordNumber).stop();
    }

    public void Next()
    {
        stopCurrentClipIfNeeded();
        m_CurrentRecored = ((m_CurrentRecored+1)%k_NumberOfSong);
        m_Records.get(m_CurrentRecored).start();
    }


    private void stopCurrentClipIfNeeded()
    {
        if (m_Records.get(m_CurrentRecored).isRunning())
        {
            m_Records.get(m_CurrentRecored).stop();
        }
    }

    public boolean IsRunning()
    {
        return m_Records.get(m_CurrentRecored).isRunning();
    }

    public void CloseRecoredSet()
    {
        for (Clip clip : m_Records)
        {
            clip.close();
        }
    }

    @Override
    public void run()
    {
        m_Records.get(m_CurrentRecored).start();
    }



}

增 编

我一贯这样做:

08/10/2011 23:47:48 LogicEngine.DJ <init>
SEVERE: null
java.io.FileNotFoundException: C:UsersDanDesktopCairoNightTrainCairoNightTrainCairoNightTrainClientsrcMusic	rain.au (‏‏System can not find the path specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:205)
        at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1162)
        at LogicEngine.DJ.createClip(DJ.java:56)
        at LogicEngine.DJ.<init>(DJ.java:42)
        at GUI.JPanelGameApplet$1.run(JPanelGameApplet.java:63)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatc
问题回答

C:UsersDanDesktopCairoNightTrainCairoNightTrainCairoNightTrainClientsrcMusic rain.au

你们的朋友是否以任何机会叫丹麦? 它无法找到这一档案。 我认为这非常清楚?

What does this print?

File file = new File("/Music/train.au");
String absolutePathOfFile = file.getAbsolutePath();
System.out.println(" The absolute path is " + absolutePathOfFile);




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签