• Post Reply Bookmark Topic Watch Topic
  • New Topic

Whitespaces in File name  RSS feed

 
Suresh Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to remove whitespaces from a file name or a path name.
eg.:- change "Program Files" to "progra~1"
change "c:/Program Files/My Program" to "C:/progra~1/myp~2/" etc.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well what you are asking is different from simply removing whitespace from the file name. What you are describing is the mapping from Windows long filenames to DOS (aka 8.3) short filenames.
Since this is a Windows-only mapping, there is no standard Java API to accomplish this.
The mapping is pretty straight-forward -- as long as you have access to the folder in which the file will reside (since the mapping is context sensitive) -- so I'm sure it's no big deal to write such a method on your own.
bear
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you need it? Chances are that the problem could be solved in a different way...
 
Suresh Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I truly believe that this is required. I am writing an InstallShield program to Install Versant Database. Versant Database does not permit any spaces in the file name. InstallShield program is very sophisticated one and since it is written with Java, a user can customize the installation program by writing custom Java Beans. I still need some way to get the file names with spaces converted to Versant can be installed. I guess 8.3 file format may be the answer.
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might need to create a JNI wrapper around GetShortPathName Win32 API call
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getshortpathname.asp
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume that you are referring to InstallShield Multi-Platform which I have used quite extensibly.
I don't have a reference handy (as I'm on holidays from work), but you might consider whether such a bean is included with ISMP or has been written as an extension. This will save you from writing the necessary JNI (yuk!) calls and use one that has already been thoroughly tested (since JNI is prone to error).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!