Fetching file and path from network using java

后端 未结 1 1026
闹比i
闹比i 2021-01-07 08:56

I need to fetch a file from network, and save the associated file path using UNC convention. And I need to import data from that file (say Excel sheet) later at particular t

相关标签:
1条回答
  • 2021-01-07 09:50

    No problem. The UNC convention is without drive letters (C:, D:) in the format

    \ \ COMPUTER \ DIR \ DIR \ FILE.

    In Java suffices File file = new File("//COMPUTER/DIR/DIR/FILE") or "\ \ \ \ COMPUTER \ \ DIR \ \ DIR \ \ FILE". (I added extraneous spaces around the backslashes.)

    file.getPath() will always yield backslashes (Windows).

    For the computer name you can use getHostName(), see: http://www.rgagnon.com/javadetails/java-0390.html

    0 讨论(0)
提交回复
热议问题