Zdravím,
chtěl bych vložit na začátek kódu zvuk, ale aby k němu nemusela být napsaná cesta(abych mohl napsat jen název souboru, vložený v NetBeans v adresáři s rozpracovaným programem)
neví někdo?
Díky předem
A když už musím takhle, co je na tom špatně? Proč se to nepřehraje?
try {
AudioClip clip = Applet.newAudioClip(
new URL("file:/C:/Users/cestaKeZvuku/zvuk.wav"));
clip.play();
} catch (MalformedURLException murle) {
System.out.println(murle);
}
A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in thejava.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.
The parent of an abstract pathname may be obtained by invoking the getParent() method of this class and consists of the pathname's prefix and each name in the pathname's name sequence except for the last. Each directory's absolute pathname is an ancestor of any File object with an absolute abstract pathname which begins with the directory's absolute pathname. For example, the directory denoted by the abstract pathname "/usr" is an ancestor of the directory denoted by the pathname "/usr/local/bin".
For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by ":" and possibly followed by "\\" if the pathname is absolute.
zaroven by bolo mudre pred pouzitim presvedcit sa ci dany subor existuje ci je skutocne subor a ci sa da citat
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku