backtrack
backtrack

Reputation: 8144

Creating folder in the local file system

I'm having the following code in my mapper [ Hadoop - Map Reduce ]

Im trying to create a folder in the shared path

protected void setup(Context context)
        throws IOException,InterruptedException 
    {

        fileName1 = ((FileSplit) context.getInputSplit()).getPath().getName().toString();
        Directory = "\\\\DEV144\\MapperFile\\"+fileName1;
        File directory1 = new File(Directory);
        if (!directory1.exists())
        {
         boolean result = new File(Directory).mkdirs(); 
         System.out.println(Directory);
        if(result)
        {    
            System.out.println("DIR created"); 
            System.out.println(Directory);          
        }
        }   
        mos = new MultipleOutputs(context);

above code is not creating the folder. But when i give something like this

Directory = "E:\\MapperFile\\"+fileName1;
File directory1 = new File(Directory);

And point the local system it is creating Folder and working fine

My question is why it is not able to create folder in the shared path ?

And what is wrong in my code

Upvotes: 0

Views: 1047

Answers (1)

user987339
user987339

Reputation: 10707

I had a similar problem and I start using jCIFS. I have to point out that this was used to access windows shared directory from a linux machine. For creating directory you can use:

String smbUrl = "smb://domain;username:password@server/share/myNewDirectory";
SmbFile smbFile = new SmbFile(smbURL);
try{    
    smbFile.mkdir();
}catch(SmbException e){...}

And don't forget to check if you have sufficient permissions for a java application.

Upvotes: 2

Related Questions