本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例13: GetFilesPathType
import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public FileType GetFilesPathType()
{
return FileType.Internal;
}
示例14: DesktopFileHandle
import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public DesktopFileHandle(FilePath path) {
super(path.toString(), FileType.Internal);
this.path = Checks.checkNotNull(path);
}
示例15: TeaVMFileHandle
import com.badlogic.gdx.Files.FileType; //导入方法依赖的package包/类
public TeaVMFileHandle(String path) {
this.type = FileType.Internal;
this.file = fixSlashes(path);
}