首页 > 编程语言 > 详细

java项目路径总结

时间:2019-10-10 17:25:00      阅读:94      评论:0      收藏:0      [点我收藏+]

1、直接输入路径

  已maven项目为例,直接输入路径的4种方式:

/**
     * FileOutpurStream以字节数组方式写入文件
     * @throws IOException
     */
    @Test
    public void testFileOutputStramBytes() throws IOException{
//        String path = "src/main/resources/write.data";
        String path = "write1.data";//在项目根目录创建
//        String localPath = "E:\\demo\\pdfCreat\\test.data";
        String localPath = "E:/demo/pdfCreat/test1.data";
        File file = new File(path);
        FileOutputStream fos = new FileOutputStream(file);
        fos.write("你好!".getBytes("utf-8"));
        fos.close();
    }
src/main/resources/write.data  项目内路径
write1.data  项目的根目录
E:\\demo\\pdfCreat\\test.data  windows系统内路径
E:/demo/pdfCreat/test1.data  同样是windows系统内路径的另一种写法


java项目路径总结

原文:https://www.cnblogs.com/whalesea/p/11649077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!