Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert UNC file name to Unix 1

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
So I need to take this:
[tt]
\\servername\folder1\folder2\
[/tt]
and convert it to a Unix file name format:

[tt]
//servername/folder1/folder2
[/tt]

I have tried using replace all, but all the ///// and \\\\\ is very confusing and I can't get it set correctly.

Anyone have any idea how to do the replacement?

Thanks!

Leslie

Have you met Hardy Heron?
 
I am using JDK1.5
Code:
public class MyStroke{
       public static void main(String args[]){
        if (args.length>0){
            System.out.println(args[0]);
           }    

        char backSlash = 92; // ascii value of "/" is 92               
        String assignedStr = ""+backSlash+backSlash+"servername"+backSlash+"folder1";
        char stroke = '/';
        String output = assignedStr.replace (backSlash,stroke);
        System.out.println("result from assignedStr :"+output);

// The following code process your input argument
        String processedInput = null;
        if (args.length>0){
             processedInput = args[0].replace(backSlash,stroke);
             System.out.println("Processed Input :"+processedInput);
           }    

       }
}
After you have compiled the Java source, you can run the program by typing:
java MyStroke \\servername\folder\folder2
 
I am sorry for my wrong remark
// ascii value of "\" is 92
 
thanks! worked like a charm:

Code:
private String ReplaceSlash (String FileName){
  char backSlash = 92; // ascii value of "/" is 92               
  String assignedStr = FileName;
  char stroke = '/';
  String output = assignedStr.replace (backSlash,stroke);
  return output;
}

unfortunately that wasn't the solution to my issue (thought that would fix it but it didn't).

Here's the issue. I am trying to get to a network location and count all the files in the specified folder (the webserver is a Linux box/file share is windows). If there are more than 12000 files in the folder, I have to create a new folder and update some information stored in the database.

When I run the process in Eclipse on my Windows XP box, it runs as expected. When we put the class into the iSeries and call it from there, the count always returns 0 and the folder is never updated.

any suggestions?

Thanks!

Leslie

Have you met Hardy Heron?
 
Ok, turns out it is probably something else.....once we figure it out i'll post what we found!

Thanks!
Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top