How to escape the white space in folder name of a file?

user3678383

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

Tobias Liefke

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can we escape the folder name having space in its name when passed from variable ?

From Dev

how to escape white space in Android Studio link to SDK/NDK

From Dev

How to continuously create file name with special character like () and white space in Linux?

From Dev

Replace white space with underscore and make lower case - file name

From Dev

Spring mvc - error with white space in file name for download

From Dev

How to start/open a file/folder that contains space in its name through command-line?

From Dev

How to download files with white space on name on Azure Blob Storage?

From Dev

How to insert white space in a file path in .emacs file?

From Dev

mv - how to escape backslash in file name?

From Dev

Space in DocumentRoot folder name

From Dev

How to add a white space

From Dev

How to keep white space as

From Dev

How to include white space when searching for a string in text file

From Dev

How to include white space when searching for a string in text file

From Dev

How to move the file in the folder to outside and change the name to the folder name?

From Dev

NSFileManager how to return folder name of file path

From Dev

How to store name of file in folder to array in c ++?

From Dev

How to change the name of an Xcode file folder?

From Dev

Rails Validate no White Space in User Name

From Dev

how to remove white space on the top

From Dev

How to ignore white space with regex?

From Dev

how to remove extra white space

From Dev

How to remove white space in datagrid

From Dev

How to remove leading white space

From Dev

How to insert white space with imagemagick?

From Dev

How to ignore white space with regex?

From Dev

GTK3 Folder Name dialog is white on white

From Dev

How to create a where query for Json in mysql with key having a white space in between the name

From Dev

how to extract specific name from folder or file name

Related Related

  1. 1

    How can we escape the folder name having space in its name when passed from variable ?

  2. 2

    how to escape white space in Android Studio link to SDK/NDK

  3. 3

    How to continuously create file name with special character like () and white space in Linux?

  4. 4

    Replace white space with underscore and make lower case - file name

  5. 5

    Spring mvc - error with white space in file name for download

  6. 6

    How to start/open a file/folder that contains space in its name through command-line?

  7. 7

    How to download files with white space on name on Azure Blob Storage?

  8. 8

    How to insert white space in a file path in .emacs file?

  9. 9

    mv - how to escape backslash in file name?

  10. 10

    Space in DocumentRoot folder name

  11. 11

    How to add a white space

  12. 12

    How to keep white space as

  13. 13

    How to include white space when searching for a string in text file

  14. 14

    How to include white space when searching for a string in text file

  15. 15

    How to move the file in the folder to outside and change the name to the folder name?

  16. 16

    NSFileManager how to return folder name of file path

  17. 17

    How to store name of file in folder to array in c ++?

  18. 18

    How to change the name of an Xcode file folder?

  19. 19

    Rails Validate no White Space in User Name

  20. 20

    how to remove white space on the top

  21. 21

    How to ignore white space with regex?

  22. 22

    how to remove extra white space

  23. 23

    How to remove white space in datagrid

  24. 24

    How to remove leading white space

  25. 25

    How to insert white space with imagemagick?

  26. 26

    How to ignore white space with regex?

  27. 27

    GTK3 Folder Name dialog is white on white

  28. 28

    How to create a where query for Json in mysql with key having a white space in between the name

  29. 29

    how to extract specific name from folder or file name

HotTag

Archive