filehandle.java

来自「导出ORACLE数据库对象DDL语句的程序」· Java 代码 · 共 41 行

JAVA
41
字号
package com.icbcsdc.ddlexp.pub.util;

import java.io.File;

/**
 * @author zhangyc
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class FileHandle {


	public static String replaceWindowsFileSeperator(File source){
		String filename=source.getPath();
		String result="";
		int begin=0;
		int end=0;
		while((begin=(filename.indexOf(File.separatorChar,end)))>0){
			result=result+filename.substring(end,begin+1)+"\\";
			end=begin+1;
		}
		result=result+filename.substring(end);		
		return result;
	}

	public static String replaceUnixFileSeperator(File source){
		String filename=source.getPath();		
		return filename.replace(File.separatorChar,'/');
	}

	public static void main(String[] args) {
		File file=new File("d:\\exp\\USERS01.DBF");
		System.out.println(FileHandle.replaceWindowsFileSeperator(file));
		File file1=new File("/exp/USERS01.DBF");
		System.out.println(FileHandle.replaceUnixFileSeperator(file1));
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?