zoukankan      html  css  js  c++  java
  • 系统变量中设定文件路径

    这是一个小例子,经过测试过的。

    package com.surekam.mpm.casemanagement.web.test;

    import java.io.File;

    import java.io.FileNotFoundException;

    import java.io.FileOutputStream;

    import java.io.IOException;

    import java.io.OutputStream;

    public class PropertyTest {

    public static void main(String[] args) throws IOException {

    System.setProperty("java.io.tmpdir", "d:\\test\\test");

    System.out.println(System.getProperty("java.io.tmpdir"));

    String filePath = System.getProperty("java.io.tmpdir");

    File file = new File(filePath);

    System.out.println(file.exists());

    if(!file.exists()){

    file.mkdirs();

    }

    file = null;

    file = new File(filePath+"\\test.txt");

    System.out.println(file.toURI().toASCIIString()+"  "+file.toURL().toString());

    try {

    OutputStream output = new FileOutputStream(file);

    output.write("我是一个中国人。".getBytes());

    output.flush();

    output.close();

    } catch (FileNotFoundException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    }

    }

  • 相关阅读:
    poj2975(nim游戏取法)
    hdu5785(极角排序求所有锐角钝角个数)
    hdu5787(数位dp)
    划分树模板
    Struts配置文件
    Struts2 调用非execute方法
    Struts简单的实例
    Struts简介
    linux yum 命令
    Linux vi/vim
  • 原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100481.html
Copyright © 2011-2022 走看看