# File Input in Java

Discussion in 'Mac Programming' started by thefil, Jul 26, 2007.

1. ### thefil macrumors newbie

Joined:
Jun 11, 2007
#1
I'm coming from a Windows environment and I have a bit of a file input problem...

Code:
`glass = new Scanner( new File("\Users\filipkrynicki\Mydia 4.0\build\classes\mydia40\db.m4"));`
returns an error "illegal escape character"

*edit* I fixed that problem by doubling the \\s, but now it can't find the file. Am I doing something wrong?

2. ### itickings macrumors 6502a

Joined:
Apr 14, 2007
#2
My guess would be the use of \ instead of /.

To avoid this kind of problem, consider using File.separator instead of assuming a specific separator.

Joined:
Nov 3, 2005
Location:
UK
#3
Totally correct \ is only the Windows separator, / is used by OS X/Unix/Linux. To run it on both the System Property File.separator is the way to go.

4. ### ChrisBrightwell macrumors 68020

Joined:
Apr 5, 2004
Location:
Huntsville, AL