Java 解析缓冲文件中的对象并将其发送到正确的构造函数时出现问题

Java 解析缓冲文件中的对象并将其发送到正确的构造函数时出现问题,java,parsing,arraylist,midi,multiple-constructors,Java,Parsing,Arraylist,Midi,Multiple Constructors,因此,我很难将我的头脑集中在一个问题上,当前正在使用缓冲读取器读取文件的midi播放器上工作。我正在将文件中的每个对象作为字符串读取到数组列表中。问题是当文件中可能有三个不同的潜在对象时,一个音符的频率是双倍的,midi音符值是int,而一个音符是字母(c4#)。如何从我构建的ArrayList中判断string对象中存在哪种类型的对象 ArrayList<String> noteList = new ArrayList<String>(); Note note;

因此,我很难将我的头脑集中在一个问题上,当前正在使用缓冲读取器读取文件的midi播放器上工作。我正在将文件中的每个对象作为字符串读取到数组列表中。问题是当文件中可能有三个不同的潜在对象时,一个音符的频率是双倍的,midi音符值是int,而一个音符是字母(c4#)。如何从我构建的ArrayList中判断string对象中存在哪种类型的对象

ArrayList<String> noteList = new ArrayList<String>();
Note note;
    String file = JOptionPane.showInputDialog("enter the file name of the song");
    String line;
    try 
    {
        BufferedReader bufread = new BufferedReader(new FileReader("res/"+file));
        while((line = bufread.readLine()) != null)
        {
            String[] result = line.split(",");
            for(String str : result)
            {
                noteList.add(str);
            }
        }
        bufread.close();
    } 
    catch (IOException e) 
    {
        e.printStackTrace();
    }
    for(int i=0; i<al.size();i++)
    {
        note = new Note(al.get(i)); //this is where the three constructors should be called
        int midiInteger = note.getMIDIAbsoluteNumber();
    channels[15].noteOn(midiInteger,127);                                
    Thread.sleep(400); 
    channels[15].noteOff(midiInteger,127);
    }

如何从string类型的数组列表中区分string或double对象。我不知道是应该更改为ArrayList并使对象注释可序列化,还是只测试ArrayList元素以获得一个字符串。或者Isleter()并从那里开始,或者有更有效的方法。

似乎正则表达式应该这样做。
Double
integer
在浮点上不同,请使用
/^[0-9]+(\\.[0-9]+)?$
对其进行测试,对于注释,这可能会有所帮助:


MIDI文件是二进制文件,而不是文本文件。您根本不应该使用
读取器
:您应该使用
输入流
,可能是
数据输入流
。或者它根本不是一个MIDI文件。对不起,我应该说清楚,被拉入的文件不是MIDI文件,它们只是用逗号分隔的.txt文件。我只是检查从文件中拆分的每个新字符串对象的数据类型。当我在一些测试中运行它时,当使用它来测试double是否与它匹配时,这个对象也适用于我
    public Note(double frequency)
    {
       frequency = this.frequency;
    }

    public Note(int noteNum)
    {
       noteNum = this.Note;
    }

    public Note(String letterNote)
    {
       letterNote = this.letterNote;
    }