This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Long File name

Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to open a file from my application by passing the filename as a string parameter here is the code for that..

import java.lang.Integer;
public class OpenFile {
public OpenFile(String fileName)
String FileName="";
String Path="";
String osName = System.getProperty("" );
Path="Start " + fileName;
if( osName.equalsIgnoreCase( "Windows NT" ) | | osName.equalsIgnoreCase("Windows 2000" )| |osName.equalsIgnoreCase( "Windows XP" ))
Path="cmd.exe Start /c" + FileName;
Runtime rt = Runtime.getRuntime();
catch(IOException io)
System.out.println("Exception thrown: " + io);
catch (IllegalArgumentException e){System.out.println("Exception thrown: " + e);
public static void main(String args[])
// please enter the filename here !!
new OpenFile("c:\\temp\\file.txt");
It doesn't work for the long file/folder names like...
c:\My Document\file.txt will not work.....
How do I solve this problem ??
Any help would be very appriciated !
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put your file in double quotes like \"<file name>\".
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic