I am developing a program in Java that associates with a file, so I useFile.separator in order to manage it.
The weird fact is that everywhere I call it, it returns the \ as it should since I am working on Windows except in the last function I use it. There, it returns the ;. I'll give you a piece of my code although I believe it won't help much. Is there anything else I should know to fix the problem?
System.out.println("File:" +source+"\n");
String filename= f.getName().substring(f.getName().lastIndexOf(File.pathSeparator)+1,f.getName().length());//here at printing I get /
System.out.println("Filename:" +filename+"\n");
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(source);
os = new FileOutputStream(output+ File.pathSeparator + filename);//here I get ;
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
} finally {
is.close();
os.close();
}