當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。