如何解决“没有这样的目录或文件”的错误?

时间:2019-05-18 18:59:36

标签: java android audio fingerprint musicg

我有这个简单的代码,但是当我运行时,我得到的错误不是这样的目录或文件!我怎么解决我尝试了许多都不起作用的方法!有人可以帮忙吗?

public static void main(字符串[] args){

    String songA = ("res/raw/canon_d_major.wav");
    String songB = ("res/raw/canon_d_major.wav");

    Wave waveA = new Wave(songA);
    Wave waveB = new Wave(songB);

    String recordedClip = ("res/raw/cock_a.1.wav");
    Wave waveRec = new Wave(recordedClip);

    FingerprintSimilarity similarity1, similarity2;

    similarity1= waveA.getFingerprintSimilarity(waveRec);

    System.out.println("clip is found at " + 
    similarity.getsetMostSimilarTimePosition() + "s in " + songA + 
    " with similarity " + similarity.getSimilarity());

    similarity2 = waveB.getFingerprintSimilarity(waveRec);

    System.out.println("clip is found at " + 
    similarity.getsetMostSimilarTimePosition() + "s in " + songB + 
    " with similarity " + similarity.getSimilarity());

}

1 个答案:

答案 0 :(得分:0)

File fileName = new File('path/to/file');未在硬盘上创建文件。它是java中唯一的新File对象,它指向您在构造函数中设置的目录。这样说来,如果执行代码时cock_a.wav不存在,则不会物理创建。

使用此-> Java's createNewFile() - will it also create directories?

此外,如果您在此处发布目录结构,可能会有所帮助。