根据路径的表创建目录

jamieAngel 2010-07-28 02:32:11
我有一个list,存有{ (aaa/bbb),(aaa/ccc),(ccc/ddd/eee)}
请问怎么根据上面的list建立起文件目录,假设他们都在c:/fff下
...全文
60 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xmx2009 2010-07-28
  • 打赏
  • 举报
回复
不会,帮顶
xieruilin 2010-07-28
  • 打赏
  • 举报
回复
public class pack
{

public static void main(String[] args) throws IOException
{
String message = null;
if(args.length <= 0)
{
System.out.println("请输入要生成文件夹的package字符串(格式如:com.abc.def):");

DataInputStream in = new DataInputStream(System.in);

message = in.readLine();
}
else
{
message = args[0];
}

try
{
pack.build(message, "c:\\");
}
catch (IOException e)
{
e.printStackTrace();
}
}

private static void build(String buildPath, String to) throws IOException
{
StringBuffer sb = new StringBuffer(to);
String[] path = buildPath.split("\\.");
for(int i = 0; i < path.length; i++)
{
sb.append(path[i]);
Process process = Runtime.getRuntime().exec("cmd /c md " + sb.toString());
InputStream in = process.getInputStream();
sb.append("\\");
while(in.read() != -1)
{
System.out.print(".");
}
}
System.out.println("生成目录为:" + sb);
}

}


把里面的"."改为你的"/"即可。
message = "ccc/ddd/eee";

33,027

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧