• 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Java drag and drop not working when dragging a file with long path name

 
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I encountered a problem where a file couldn't be copied from one place to another using drag and drop feature of java. I think the problem is the pathname because some files that I dragged got copied well except from files with long path names. The program is being run in Windows 7 and I'm aware of Windows 7 path name limit(which is 255-260 according to the sources that I've read). When I used windows explorer to drag files the file with long path name got copied successfully. My solution here is to inform the user about the long file path name and let them shorten the path name. I just wanna know if there's a solution to bypass that long path name problem like windows explorer does?

This is the length of the file that I was talking about


The program is also being used to drag files from the program to a file hosting website and website gives this error

 
Marshal
Posts: 26598
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you drag the long file name and drop it into a text editor, do you see the file name with the last part chopped off?
 
Elya Matsunomi
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I used notepad++ and it displayed the full path of the file.  The full path is also displayed in the web browser when I do drag and drop to the browser. However, File not found error appeared.
 
Paul Clapham
Marshal
Posts: 26598
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So Java drag-and-drop is providing the correct file name to the browser, but the browser has a problem with that file name? Then I don't see why the problem is related to Java drag-and-drop in any way.

If you try copying the long file name from Notepad++ and pasting it into the browser, what happens? Prediction: the browser will have a problem.
 
Elya Matsunomi
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, this is the file uploader without any items


This is the result if I drag and drop file with long path name using windows explorer

In this attempt. the file is successfully loaded to the file uploader all I need to do is to click the upload button

This is the result If I drag and drop file with long path name using java


The problem only happens in files with long path names. Windows explorer drag and drop and java drag and drop work well with file with short path name. When it comes to long path name, Windows explorer drag and drop still works but java drag and drop doesn't
 
Saloon Keeper
Posts: 23689
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Drag and drop in a browser window is more likely to be a JavaScript issue than a Java one.  Unless you're running an applet, Java code does not run on the web client side.
 
Elya Matsunomi
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also tried to compare the windows explorer and java drag and drop on desktop and java drag and drop still has the problem. When I use windows explorer to drag a file with long path name to desktop, It successfully copied the file to desktop. Java, on the other hand, didn't successfully copy the file.

I also noticed that file path of the file with long file name is somewhat weird when I look at its properties in windows explorer

Portion of the path of file with long path name
D:\LOGICA~1\Uploads\

Portion of the path of file with short path name
D:\Logical(Not Installed) Files\Uploads\

Though, The path of the file with long path name that I'm getting in java is normal.

 
Tim Holloway
Saloon Keeper
Posts: 23689
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Windows carries a legacy from DOS which got its original filesystem and I/O services from floppy disks which had 11-character fixed character slots for filenames: 8 for the base name and 3 for the extension. Known as "8.3" notation.

When Windows took over, it added more intelligent filesystems - notably NTFS - which no longer carried that restriction. But to support legacy DOS programs, mechanisms were built in to curtate long names into 8.3-friendly forms. Such as "LOGICA~1". Or one that everyone loves, PROGRA~1 for "Program Files".

Note that this curtation system is not wholly predictable. In cases of collision, other values may be used. I have seen the occasional PROGRA~2 directory, for example.

Java, of course, being write-once/run-anywhere has no use for such foolishness and never employs, requires or enforces 8.3 itself.
 
Elya Matsunomi
Greenhorn
Posts: 25
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like there's no solid solution to this long path name problem then.  Thanks for the help I really appreciate it.
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic