Java 在本地文件系统中创建文件夹
我的映射程序[Hadoop-MapReduce]中有以下代码 我正在尝试在共享路径中创建文件夹Java 在本地文件系统中创建文件夹,java,hadoop,directory,Java,Hadoop,Directory,我的映射程序[Hadoop-MapReduce]中有以下代码 我正在尝试在共享路径中创建文件夹 protected void setup(Context context) throws IOException,InterruptedException { fileName1 = ((FileSplit) context.getInputSplit()).getPath().getName().toString(); Directory
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);
上面的代码没有创建文件夹。但是当我给你这样的东西的时候
Directory = "E:\\MapperFile\\"+fileName1;
File directory1 = new File(Directory);
并指出本地系统正在创建文件夹,工作正常
我的问题是为什么它不能在共享路径中创建文件夹
我的代码出了什么问题?我遇到了类似的问题,开始使用。我必须指出,这是用来从linux机器访问windows共享目录的。要创建目录,您可以使用:
String smbUrl = "smb://domain;username:password@server/share/myNewDirectory";
SmbFile smbFile = new SmbFile(smbURL);
try{
smbFile.mkdir();
}catch(SmbException e){...}
别忘了检查您是否有足够的权限使用java应用程序。您的用户有权在共享文件夹中创建目录吗?@OskarKjellin是的,我正在以管理员权限运行它