当前位置: 首页>>代码示例>>Java>>正文


Java Util类代码示例

本文整理汇总了Java中org.apache.harmony.luni.util.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Util类属于org.apache.harmony.luni.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextEntry

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Returns the next {@code ZipEntry} contained in this stream or {@code
 * null} if no more entries are present.
 *
 * @return the next extracted ZIP entry.
 * @throws IOException
 *             if an error occurs while reading the entry.
 */
@Override
public ZipEntry getNextEntry() throws IOException {
    if (mEntry != null) {
        jarEntry = mEntry;
        mEntry = null;
        jarEntry.setAttributes(null);
    } else {
        jarEntry = (JarEntry) super.getNextEntry();
        if (jarEntry == null) {
            return null;
        }
        if (verifier != null) {
            isMeta = Util.toASCIIUpperCase(jarEntry.getName()).startsWith(
                    JarFile.META_DIR);
            if (isMeta) {
                verStream = new ByteArrayOutputStream();
            } else {
                verStream = verifier.initEntry(jarEntry.getName());
            }
        }
    }
    eos = false;
    return jarEntry;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:33,代码来源:JarInputStream.java

示例2: decodeActions

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
private void decodeActions(String actions) {
    StringTokenizer tokenizer = new StringTokenizer(Util.toASCIILowerCase(actions),
            " \t\n\r,");
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (token.equals("read")) {
            read = true;
        } else if (token.equals("write")) {
            write = true;
        } else {
            throw new IllegalArgumentException();
        }
    }
    if (!read && !write) {
        throw new IllegalArgumentException();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:PropertyPermission.java

示例3: decodeActions

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
private void decodeActions(String actions) {
    StringTokenizer tokenizer = new StringTokenizer(Util.toASCIILowerCase(actions),
            " \t\n\r,"); //$NON-NLS-1$
    while (tokenizer.hasMoreTokens()) {
        String token = tokenizer.nextToken();
        if (token.equals("read")) { //$NON-NLS-1$
            read = true;
        } else if (token.equals("write")) { //$NON-NLS-1$
            write = true;
        } else {
            throw new IllegalArgumentException();
        }
    }
    if (!read && !write) {
        throw new IllegalArgumentException();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:PropertyPermission.java

示例4: Locale

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Constructs a new Locale using the specified language, country, and
 * variant codes.
 * 
 * @param language
 * @param country
 * @param variant
 * @throws NullPointerException if <code>language</code>,
 *         <code>country</code> or <code>variant</code> is
 *         <code>null</code>.
 */
public Locale(String language, String country, String variant) {
    if (language == null || country == null || variant == null) {
        throw new NullPointerException();
    }
    languageCode = Util.toASCIILowerCase(language);
    // Map new language codes to the obsolete language
    // codes so the correct resource bundles will be used.
    if (languageCode.equals("he")) {//$NON-NLS-1$
        languageCode = "iw"; //$NON-NLS-1$
    } else if (languageCode.equals("id")) {//$NON-NLS-1$
        languageCode = "in"; //$NON-NLS-1$
    } else if (languageCode.equals("yi")) {//$NON-NLS-1$
        languageCode = "ji"; //$NON-NLS-1$
    }

    // countryCode is defined in ASCII character set
    countryCode = Util.toASCIIUpperCase(country);

    variantCode = variant;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:32,代码来源:Locale.java

示例5: list

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Answers an array of Strings representing the file names in the directory
 * represented by this File. If this File is not a directory the result is
 * <code>null</code>.
 * <p>
 * The entries <code>.</code> and <code>..</code> representing current
 * directory and parent directory are not returned as part of the list.
 * 
 * @return an array of Strings or <code>null</code>.
 * 
 * @see #getPath
 * @see #isDirectory
 * @see java.lang.SecurityManager#checkRead(FileDescriptor)
 */
public java.lang.String[] list() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkRead(path);
    }
    if (!isDirectory()) {
        return null;
    }
    byte[][] implList = listImpl(properPath(true));
    if (implList == null) {
        return new String[0];
    }
    String result[] = new String[implList.length];
    for (int index = 0; index < implList.length; index++) {
        result[index] = Util.toString(implList[index]);
    }
    return result;
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:33,代码来源:File.java

示例6: listFiles

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Answers an array of Files representing the file names in the directory
 * represented by this File that match a specific filter. If this File is
 * not a directory the result is <code>null</code>. If the filter is
 * <code>null</code> then all filenames match.
 * <p>
 * The entries <code>.</code> and <code>..</code> representing current
 * directory and parent directory are not returned as part of the list.
 * 
 * @param filter
 *            the filter to match names to or <code>null</code>.
 * @return an array of Files or <code>null</code>.
 * 
 * @see #getPath
 * @see #isDirectory
 * @see java.lang.SecurityManager#checkRead(FileDescriptor)
 */
public File[] listFiles(FileFilter filter) {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkRead(path);
    }
    if (!isDirectory()) {
        return null;
    }
    byte[][] implList = listImpl(properPath(true));
    if (implList == null) {
        return new File[0];
    }
    List<File> tempResult = new ArrayList<File>();
    for (int index = 0; index < implList.length; index++) {
        String aName = Util.toString(implList[index]);
        File aFile = new File(this, aName);
        if (filter == null || filter.accept(aFile)) {
            tempResult.add(aFile);
        }
    }
    return tempResult.toArray(new File[tempResult.size()]);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:40,代码来源:File.java

示例7: FileURLConnection

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Creates an instance of <code>FileURLConnection</code> for establishing
 * a connection to the file pointed by this <code>URL<code>
 *
 * @param url The URL this connection is connected to
 */
public FileURLConnection(URL url) {
    super(url);
    fileName = url.getFile();
    if (url.getRef() != null) {
        fileName += "#" + url.getRef(); //$NON-NLS-1$
    }
    if (fileName == null) {
        fileName = ""; //$NON-NLS-1$
    }
    String host = url.getHost();
    if (host != null && host.length() > 0) {
        fileName = "//" + host + fileName; //$NON-NLS-1$
    }
    fileName = Util.decode(fileName, false);
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:22,代码来源:FileURLConnection.java

示例8: decodeUTF

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
private static String decodeUTF(int utfSize, DataInput in) throws IOException {
    byte[] buf = new byte[utfSize];
    char[] out = new char[utfSize];
    in.readFully(buf, 0, utfSize);

    return Util.convertUTF8WithBuf(buf, out, 0, utfSize);
}
 
开发者ID:cloudeecn,项目名称:fiscevm,代码行数:8,代码来源:DataInputStream.java

示例9: readUTF

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
public String readUTF() throws IOException {
	ByteOrder byteOrder = getByteOrder();
	setByteOrder(ByteOrder.BIG_ENDIAN);
	final int size = readUnsignedShort();
	final byte[] buf = new byte[size];
	final char[] out = new char[size];

	readFully(buf, 0, size);
	setByteOrder(byteOrder);
	//return new DataInputStream(new ByteArrayInputStream(buff)).readUTF();
	return Util.convertUTF8WithBuf(buf, out, 0, size);
}
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:13,代码来源:ImageInputStreamImpl.java

示例10: JarInputStream

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Constructs a new {@code JarInputStream} from an input stream.
 *
 * @param stream
 *            the input stream containing the JAR file.
 * @param verify
 *            if the file should be verified with a {@code JarVerifier}.
 * @throws IOException
 *             If an error occurs reading entries from the input stream.
 * @see ZipInputStream#ZipInputStream(InputStream)
 */
public JarInputStream(InputStream stream, boolean verify)
        throws IOException {
    super(stream);
    if (verify) {
        verifier = new JarVerifier("JarInputStream");
    }
    if ((mEntry = getNextJarEntry()) == null) {
        return;
    }
    String name = Util.toASCIIUpperCase(mEntry.getName());
    if (name.equals(JarFile.META_DIR)) {
        mEntry = null; // modifies behavior of getNextJarEntry()
        closeEntry();
        mEntry = getNextJarEntry();
        name = mEntry.getName().toUpperCase();
    }
    if (name.equals(JarFile.MANIFEST_NAME)) {
        mEntry = null;
        manifest = new Manifest(this, verify);
        closeEntry();
        if (verify) {
            verifier.setManifest(manifest);
            if (manifest != null) {
                verifier.mainAttributesEnd = manifest
                        .getMainAttributesEnd();
            }
        }

    } else {
        Attributes temp = new Attributes(3);
        temp.map.put("hidden", null);
        mEntry.setAttributes(temp);
        /*
         * if not from the first entry, we will not get enough
         * information,so no verify will be taken out.
         */
        verifier = null;
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:51,代码来源:JarInputStream.java

示例11: Locale

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Constructs a new {@code Locale} using the specified language, country,
 * and variant codes.
 */
public Locale(String language, String country, String variant) {
    if (language == null || country == null || variant == null) {
        throw new NullPointerException();
    }
    if(language.isEmpty() && country.isEmpty()){
        languageCode = "";
        countryCode = "";
        variantCode = variant;
        return;
    }
    // BEGIN android-changed
    // this.uLocale = new ULocale(language, country, variant);
    // languageCode = uLocale.getLanguage();
    languageCode = Util.toASCIILowerCase(language);
    // END android-changed
    // Map new language codes to the obsolete language
    // codes so the correct resource bundles will be used.
    if (languageCode.equals("he")) {
        languageCode = "iw";
    } else if (languageCode.equals("id")) {
        languageCode = "in";
    } else if (languageCode.equals("yi")) {
        languageCode = "ji";
    }

    // countryCode is defined in ASCII character set
    // BEGIN android-changed
    // countryCode = country.length()!=0?uLocale.getCountry():"";
    countryCode = Util.toASCIIUpperCase(country);
    // END android-changed

    // Work around for be compatible with RI
    variantCode = variant;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:39,代码来源:Locale.java

示例12: FileURLConnection

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Creates an instance of <code>FileURLConnection</code> for establishing
 * a connection to the file pointed by this <code>URL<code>
 *
 * @param url The URL this connection is connected to
 */
public FileURLConnection(URL url) {
    super(url);
    fileName = url.getFile();
    if (fileName == null) {
        fileName = "";
    }
    fileName = Util.decode(fileName, false);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:FileURLConnection.java

示例13: JarInputStream

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Constructs a new {@code JarInputStream} from an input stream.
 *
 * @param stream
 *            the input stream containing the JAR file.
 * @param verify
 *            if the file should be verified with a {@code JarVerifier}.
 * @throws IOException
 *             If an error occurs reading entries from the input stream.
 * @see ZipInputStream#ZipInputStream(InputStream)
 */
public JarInputStream(InputStream stream, boolean verify)
        throws IOException {
    super(stream);
    if (verify) {
        verifier = new JarVerifier("JarInputStream"); //$NON-NLS-1$
    }
    if ((mEntry = getNextJarEntry()) == null) {
        return;
    }
    String name = Util.toASCIIUpperCase(mEntry.getName());
    if (name.equals(JarFile.META_DIR)) {
        mEntry = null; // modifies behavior of getNextJarEntry()
        closeEntry();
        mEntry = getNextJarEntry();
        name = mEntry.getName().toUpperCase();
    }
    if (name.equals(JarFile.MANIFEST_NAME)) {
        mEntry = null;
        manifest = new Manifest(this, verify);
        closeEntry();
        if (verify) {
            verifier.setManifest(manifest);
            if (manifest != null) {
                verifier.mainAttributesEnd = manifest
                        .getMainAttributesEnd();
            }
        }

    } else {
        Attributes temp = new Attributes(3);
        temp.map.put("hidden", null); //$NON-NLS-1$
        mEntry.setAttributes(temp);
        /*
         * if not from the first entry, we will not get enough
         * information,so no verify will be taken out.
         */
        verifier = null;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:51,代码来源:JarInputStream.java

示例14: listRoots

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Lists the file system roots. The Java platform may support zero or more
 * file systems, each with its own platform-dependent root. Further, the
 * canonical pathname of any file on the system will always begin with one
 * of the returned file system roots.
 * 
 * @return the array of file system roots.
 */
public static File[] listRoots() {
    byte[][] rootsList = rootsImpl();
    if (rootsList == null) {
        return new File[0];
    }
    File result[] = new File[rootsList.length];
    for (int i = 0; i < rootsList.length; i++) {
        result[i] = new File(Util.toString(rootsList[i]));
    }
    return result;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:File.java

示例15: list

import org.apache.harmony.luni.util.Util; //导入依赖的package包/类
/**
 * Returns an array of strings with the file names in the directory
 * represented by this file. The result is {@code null} if this file is not
 * a directory.
 * <p>
 * The entries {@code .} and {@code ..} representing the current and parent
 * directory are not returned as part of the list.
 *
 * @return an array of strings with file names or {@code null}.
 * @throws SecurityException
 *             if a {@code SecurityManager} is installed and it denies read
 *             access to this file.
 * @see #isDirectory
 * @see java.lang.SecurityManager#checkRead(FileDescriptor)
 */
public java.lang.String[] list() {
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkRead(path);
    }

    if (path.length() == 0) {
        return null;
    }

    byte[] bs = properPath(true);
    if (!isDirectoryImpl(bs) || !existsImpl(bs) || isWriteOnlyImpl(bs)) {
        return null;
    }

    byte[][] implList = listImpl(bs);
    if (implList == null) {
        // empty list
        return new String[0];
    }
    String result[] = new String[implList.length];
    for (int index = 0; index < implList.length; index++) {
        result[index] = Util.toUTF8String(implList[index]);
    }
    return result;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:42,代码来源:File.java


注:本文中的org.apache.harmony.luni.util.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。