This site requires JavaScript, please enable it in your browser!
Greenfoot back
SPower
SPower wrote ...

2012/7/17

Enter a '\' sign in a String

SPower SPower

2012/7/17

#
Hi all, I'm having trouble entering this in a string: "folder\somefile.mp3" to create a GreenfootSound instance. Can anyone help me? Thanks.
erdelf erdelf

2012/7/17

#
why do you want a specific folder, just use the sound folder.
davmac davmac

2012/7/17

#
Backslash is an escape character in Java strings. The easiest thing is to use a forward slash instead - "folder/somefile.mp3". This will work on Windows, but as an added bonus, will also work on other systems, and when you upload your scenario to the greenfoot website. Backslash won't. If you really did want a backslash in a string, you'd need to double it: "folder\\somefile.mp3"
SPower SPower

2012/7/17

#
@davmac Thanks, I thought it was a \ sign but it is a / sign, I learned something useful (and basic :) ). @erdelf I have multiple background sound files, and I want to sort them.
You need to login to post a reply.