Consider the source_folder_name
as D:\Desktop\test util\config sql
In the code given below the white space in the folder name i.e test util
and config sql
is not handled properly. I need to escape those white spaces.
public class SqlToTblCoverter {
private File source_folder = null;
public SqlToTblCoverter(String source_folder_name) {
source_folder = new File(source_folder_name);
}
public void check() {
System.out.println("Source folder"+ source_folder);
}
}
public class test{
public static void main(String args[]){
Scanner in=new Scanner(System.in);
System.out.println("Enter Input Folder Path");
String input=in.next();
SqlToTblCoverter config_migrator = new
SqlToTblCoverter(input);
}
}
On executing the above code the value of source_folder comes is
Source folder: D:\Desktop\test
whereas expected is
Source folder: D:\Desktop\test util\config sql
Please help me out
If you read the documentation of Scanner
you will see:
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.
So the problem is your scanner. If you use the newlines as delimiter, everything should work as expected.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments