package com.platform.test;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

import org.junit.Test;

import com.platform.utils.FileOperateHelper;

public class FileOperationTest {
	
	@Test
	public void addLastSeparator() {
		System.out.println(FileOperateHelper.addLastSeparator("D:/gitTmp3/aggregation-platform"));

	}
	@Test
	public void removeLastSeparator() {
		System.out.println(FileOperateHelper.removeLastSeparator("D:/gitTmp3/aggregation-platform/"));

	}
	
	@Test
	public void fileCreate() {
		File f = new File("D:/Create1");
		f.mkdir();
		File f2 = new File("D:/Create1/1.txt");
		try {
			f2.createNewFile();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		File f3 = new File("D:/Create1");
		f3.mkdir();
		
	}
	
	@Test
	public void reWriteFile() {
		
		FileOperateHelper.fileReWrite("D:/test/1.txt", "asdadada\r\n");
		FileOperateHelper.fileReWrite("D:/test/1.txt", "asdadada\r\n");
		FileOperateHelper.fileReWrite("D:/test/1.txt", "asdaaaaaaaaa\r\n");
	}
	
	@Test
	public void WriteFile() {
		
		FileOperateHelper.fileWrite("D:/test/1.txt", "asdadada\r\n");
		FileOperateHelper.fileWrite("D:/test/1.txt", "asdadada\r\n");
		FileOperateHelper.fileWrite("D:/test/1.txt", "asdaaaaaaaaa\r\n");
	}
	
	@Test
	public void getsystem() {
		Properties sys = System.getProperties();
		System.out.println(sys.getProperty("os.name"));

	}
	
	@Test
	public void testsep() {
		String sep = "d:\\e\\w\\";
		if (sep.endsWith(File.separator)) {
			String path = sep.substring(0, sep.length()-1);
			System.out.println(path);
		}
		System.err.println("---");

	}

}
