filenamedeal.java

来自「动画素材图像语义标注系统:该系统实现对图片的语义标注」· Java 代码 · 共 55 行

JAVA
55
字号
package cn.dxm.util;

import java.util.ArrayList;

public class FileNameDeal {

	private String endWith;

	public FileNameDeal() {
	}

	public FileNameDeal(String endWith) {
		this.endWith = endWith;
	}

	public String getFileNameEnds() {
		String result = null;
		int beginIndex = endWith.lastIndexOf('.') + 1;
		int endIndex = endWith.length();
		result = endWith.substring(beginIndex, endIndex);
		return result;
	}

	// 叛断一个文件是否为一张图片.根据后缀来叛.
	public boolean wetherIsIMG(String end) {

		if (end.equals("jpg") || end.equals("JPG") || end.equals("GIF") || end.equals("JPEG") || end.equals("jpeg")
				|| end.equals("gif") || end.equals("PNG") || end.equals("png")||end.equals("bmp")||end.equals("BMP"))
			return true;

		else
			return false;
	}

	public int locationIMG(ArrayList list, String imageName) {
		int result = 0;
		result = list.indexOf(imageName);
		return result;
	}

	// 如果文件名有扣缀,前为图片后缀,即为.jpg,.png,.gif则,返回true.否则返回false;

	public static boolean whetherAImageName(String imageName) {

		if (imageName.endsWith(".jpg") || imageName.endsWith(".JPG")
				|| imageName.endsWith(".gif") || imageName.endsWith(".GIF")
				|| imageName.endsWith(".png") || imageName.endsWith(".PNG")
				)
			return true;
		
		else return false;
	}

}

⌨️ 快捷键说明

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