📄 util.java
字号:
/* * Tiled Map Editor, (c) 2004-2006 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Adam Turk <aturk@biggeruniverse.com> * Bjorn Lindeijer <b.lindeijer@xs4all.nl> */package tiled.util;import java.io.File;import java.io.IOException;/** * Various utility functions * * $Id: Util.java 683 2006-06-25 14:17:37Z bjorn $ */public class Util{ /** * This function converts an <code>int</code> integer array to a * <code>byte</code> array. Each integer element is broken into 4 bytes and * stored in the byte array in litte endian byte order. * * @param integers an integer array * @return a byte array containing the values of the int array. The byte * array is 4x the length of the integer array. */ public static byte[] convertIntegersToBytes (int[] integers) { if (integers != null) { byte[] outputBytes = new byte[integers.length * 4]; for(int i = 0, k = 0; i < integers.length; i++) { int integerTemp = integers[i]; for(int j = 0; j < 4; j++, k++) { outputBytes[k] = (byte)((integerTemp >> (8 * j)) & 0xFF); } } return outputBytes; } else { return null; } } /** * This utility function will check the specified string to see if it * starts with one of the OS root designations. (Ex.: '/' on Unix, 'C:' on * Windows) * * @param filename a filename to check for absolute or relative path * @return <code>true</code> if the specified filename starts with a * filesystem root, <code>false</code> otherwise. */ public static boolean checkRoot(String filename) { File[] roots = File.listRoots(); for (int i = 0; i < roots.length; i++) { try { String root = roots[i].getCanonicalPath().toLowerCase(); if (filename.toLowerCase().startsWith(root)) { return true; } } catch (IOException e) { // Do we care? } } return false; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -