A
A
Andy Voz2016-02-02 08:59:21
Java
Andy Voz, 2016-02-02 08:59:21

Javafx.scene.media.AudioClip; How to play a file whose name contains spaces???

In general, in the process of studying java and javaFX API in particular, I decided to write a simple audio player. In the process, I encountered the fact that the AudioClip class, which I planned to use to play files, does not want to play files whose name contains a space.
Question: Is there any way to fix this?
PS Files without spaces in the name are played perfectly.
PPS I don't see any reason to apply the entire source code, the main exciting piece is:
AudioClip player = new AudioClip(filepath);
player.play();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Dorofeev, 2016-02-02
@AndreyVoznyk

Try to go through File:

File file = new File("Путь к файлу с пробелами");
String path = file.toURI().toASCIIString();

D
de_iiah_teji9_iiace, 2016-02-02
@de_iiah_teji9_iiace

Read here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question