@Override public void create () { // copy an internal mp3 to the external storage FileHandle src = Gdx.files.internal("data/8.12.mp3"); FileHandle dst = Gdx.files.external("8.12.mp3"); src.copyTo(dst); // create a music instance and start playback Music music = Gdx.audio.newMusic(dst); music.play(); }
/** 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) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }
/** 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) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }
copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (!copy.exists()) fail(); if (copy.length() != 3) fail();
copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (!copy.exists()) fail(); if (copy.length() != 3) fail();
copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (!copy.exists()) fail(); if (copy.length() != 3) fail();
copy.delete(); if (copy.exists()) fail(); handle.copyTo(copy); if (!copy.exists()) fail(); if (copy.length() != 68465) fail();
public void create() { ... FileHandle internalFile = Gdx.files.internal(scenarioName); internalFile.copyTo(Gdx.files.local(scenarioName); }
FileHandle file=Gdx.files.internal(filepath); FileHandle external=Gdx.files.external("mygame/"+filepath); if(!external.exists())file.copyTo(external); //copy the file to the external storage Mpg123Decoder decoder = new Mpg123Decoder(external); System.out.println("name:"+filepath+" duration:"+decoder.getLength());
if(!external.exists())file.copyTo(external); //copy the file to the external storage only if it doesnt exists yet decoder = new Mpg123Decoder(external); device = Gdx.audio.newAudioDevice(decoder.getRate(),decoder.getChannels() == 1 ? true : false);
input.copyTo(tempFile); input.delete(); input = tempFile;
testFile.copyTo(Gdx.files.external("test-copy.txt")); string = testCopy.readString(); System.out.println(string.equals(testString) ? "Successfully copied file" : "Failed to copy file");
@LmlAction("editCustomHotkeys") void editCustomHotkeys() { FileHandle userHotkeyFile = Gdx.files.external(AppConstants.EXTERNAL_DIR + "/hotkeys_user.txt"); if (!userHotkeyFile.exists()) { Gdx.files.internal("hotkeys_user.txt").copyTo(userHotkeyFile); } try { Desktop.getDesktop().open(userHotkeyFile.file()); } catch (IOException e) { Gdx.app.error(TAG, "Error opening " + userHotkeyFile, e); } } @LmlAction public void showMenuFile() {
/** 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) { switch (type) { case Classpath: throw new GdxRuntimeException("Cannot move a classpath file: " + file); case Internal: throw new GdxRuntimeException("Cannot move an internal file: " + file); case Absolute: case External: // Try rename for efficiency and to change case on case-insensitive file systems. if (file().renameTo(dest.file())) return; } copyTo(dest); delete(); if (exists() && isDirectory()) deleteDirectory(); }