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


Java FileType.Internal方法代码示例

本文整理汇总了Java中com.badlogic.gdx.Files.FileType.Internal方法的典型用法代码示例。如果您正苦于以下问题:Java FileType.Internal方法的具体用法?Java FileType.Internal怎么用?Java FileType.Internal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.Files.FileType的用法示例。


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

示例1: list

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public FileHandle[] list (String suffix) {
	if (type == FileType.Internal) {
		try {
			String[] relativePaths = assets.list(file.getPath());
			FileHandle[] handles = new FileHandle[relativePaths.length];
			int count = 0;
			for (int i = 0, n = handles.length; i < n; i++) {
				String path = relativePaths[i];
				if (!path.endsWith(suffix)) continue;
				handles[count] = new AndroidFileHandle(assets, new File(file, path), type);
				count++;
			}
			if (count < relativePaths.length) {
				FileHandle[] newHandles = new FileHandle[count];
				System.arraycopy(handles, 0, newHandles, 0, count);
				handles = newHandles;
			}
			return handles;
		} catch (Exception ex) {
			throw new GdxRuntimeException("Error listing children: " + file + " (" + type + ")", ex);
		}
	}
	return super.list(suffix);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:AndroidFileHandle.java

示例2: read

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns a stream for reading this file as bytes.
 * @throws GdxRuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */
public InputStream read () {
	if (type == FileType.Classpath || (type == FileType.Internal && !file().exists())
		|| (type == FileType.Local && !file().exists())) {
		InputStream input = FileHandle.class.getResourceAsStream("/" + file.getPath().replace('\\', '/'));
		if (input == null) throw new GdxRuntimeException("File not found: " + file + " (" + type + ")");
		return input;
	}
	try {
		return new FileInputStream(file());
	} catch (Exception ex) {
		if (file().isDirectory())
			throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
		throw new GdxRuntimeException("Error reading file: " + file + " (" + type + ")", ex);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:FileHandle.java

示例3: writer

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns a writer for writing to this file. Parent directories will be created if necessary.
 * @param append If false, this file will be overwritten if it exists, otherwise it will be appended.
 * @param charset May be null to use the default charset.
 * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or
 *            {@link FileType#Internal} file, or if it could not be written. */
public Writer writer (boolean append, String charset) {
	if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file);
	if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file);
	parent().mkdirs();
	try {
		FileOutputStream output = new FileOutputStream(file(), append);
		if (charset == null)
			return new OutputStreamWriter(output);
		else
			return new OutputStreamWriter(output, charset);
	} catch (IOException ex) {
		if (file().isDirectory())
			throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
		throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:FileHandle.java

示例4: exists

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public boolean exists () {
	if (type == FileType.Internal) {
		String fileName = file.getPath();
		try {
			assets.open(fileName).close(); // Check if file exists.
			return true;
		} catch (Exception ex) {
			// This is SUPER slow! but we need it for directories.
			try {
				return assets.list(fileName).length > 0;
			} catch (Exception ignored) {
			}
			return false;
		}
	}
	return super.exists();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:AndroidFileHandle.java

示例5: read

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns a stream for reading this file as bytes.
 * @throw GdxRuntimeException if the file handle represents a directory, doesn't exist, or could not be read. */
public InputStream read () {
	if (type == FileType.Classpath || (type == FileType.Internal && !file.exists())
		|| (type == FileType.Local && !file.exists())) {
		InputStream input = FileWrapper.class.getResourceAsStream("/" + file.getPath().replace('\\', '/'));
		if (input == null) throw new GdxRuntimeException("File not found: " + file + " (" + type + ")");
		return input;
	}
	try {
		return new FileInputStream(file());
	} catch (Exception ex) {
		if (file().isDirectory())
			throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
		throw new GdxRuntimeException("Error reading file: " + file + " (" + type + ")", ex);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:FileWrapper.java

示例6: writer

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns a writer for writing to this file. Parent directories will be created if necessary.
 * @param append If false, this file will be overwritten if it exists, otherwise it will be appended.
 * @param charset May be null to use the default charset.
 * @throw GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or
 *        {@link FileType#Internal} file, or if it could not be written. */
public Writer writer (boolean append, String charset) {
	if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file);
	if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file);
	parent().mkdirs();
	try {
		FileOutputStream output = new FileOutputStream(file(), append);
		if (charset == null)
			return new OutputStreamWriter(output);
		else
			return new OutputStreamWriter(output, charset);
	} catch (IOException ex) {
		if (file().isDirectory())
			throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
		throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:FileWrapper.java

示例7: isDirectory

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public boolean isDirectory () {
	if (type == FileType.Internal) {
		try {
			return assets.list(file.getPath()).length > 0;
		} catch (IOException ex) {
			return false;
		}
	}
	return super.isDirectory();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:11,代码来源:AndroidFileHandle.java

示例8: moveTo

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Moves this file to the specified file, overwriting the file if it already exists.
 * @throws GdxRuntimeException if the source or destination file handle is a {@link FileType#Classpath} or
 *            {@link FileType#Internal} file. */
public void moveTo (FileHandle dest) {
	if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot move a classpath file: " + file);
	if (type == FileType.Internal) throw new GdxRuntimeException("Cannot move an internal file: " + file);
	copyTo(dest);
	delete();
	if (exists() && isDirectory()) deleteDirectory();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:11,代码来源:FileHandle.java

示例9: length

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns the length in bytes of this file, or 0 if this file is a directory, does not exist, or the size cannot otherwise be
 * determined. */
public long length () {
	if (type == FileType.Classpath || (type == FileType.Internal && !file.exists())) {
		InputStream input = read();
		try {
			return input.available();
		} catch (Exception ignored) {
		} finally {
			StreamUtils.closeQuietly(input);
		}
		return 0;
	}
	return file().length();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:16,代码来源:FileHandle.java

示例10: write

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Returns a stream for writing to this file. Parent directories will be created if necessary.
 * @param append If false, this file will be overwritten if it exists, otherwise it will be appended.
 * @throw GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or
 *        {@link FileType#Internal} file, or if it could not be written. */
public OutputStream write (boolean append) {
	if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot write to a classpath file: " + file);
	if (type == FileType.Internal) throw new GdxRuntimeException("Cannot write to an internal file: " + file);
	parent().mkdirs();
	try {
		return new FileOutputStream(file(), append);
	} catch (Exception ex) {
		if (file().isDirectory())
			throw new GdxRuntimeException("Cannot open a stream to a directory: " + file + " (" + type + ")", ex);
		throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:FileWrapper.java

示例11: moveTo

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
/** Moves this file to the specified file, overwriting the file if it already exists.
 * @throw GdxRuntimeException if the source or destination file handle is a {@link FileType#Classpath} or
 *        {@link FileType#Internal} file. */
public void moveTo (FileWrapper dest) {
	if (type == FileType.Classpath) throw new GdxRuntimeException("Cannot move a classpath file: " + file);
	if (type == FileType.Internal) throw new GdxRuntimeException("Cannot move an internal file: " + file);
	copyTo(dest);
	delete();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:FileWrapper.java

示例12: file

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
@Override
public File file() {
    if (type == FileType.Internal) return new File(internalPath, file.getPath());
    if (type == FileType.External) return new File(externalPath, file.getPath());
    if (type == FileType.Local) return new File(localPath, file.getPath());
    return file;
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:8,代码来源:LibgdxLoggerIosFileHandle.java

示例13: GetFilesPathType

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public FileType GetFilesPathType()
{
	return FileType.Internal;
}
 
开发者ID:mitsuhirato,项目名称:TheEndlessCastle,代码行数:5,代码来源:AssetsHandler.java

示例14: DesktopFileHandle

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public DesktopFileHandle(FilePath path) {
    super(path.toString(), FileType.Internal);

    this.path = Checks.checkNotNull(path);
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:6,代码来源:DesktopGdxFileSystem.java

示例15: TeaVMFileHandle

import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public TeaVMFileHandle(String path) {
    this.type = FileType.Internal;
    this.file = fixSlashes(path);
}
 
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:5,代码来源:TeaVMFileHandle.java


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