Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Dateien löschen

Empfohlene Antworten

Veröffentlicht

Hallo erstmal!

Ich suche ne Lösung für folgendes Problem:

Ich möchte aus einem Java-Programm raus durch einen Button eine Datei löschen, deren Pathangabe ich in einem Textfeld eingebe. Hab also einen String. Wie kann ich die Pathangabe jetzt der delete -Funktion mitgeben? Die greift ja nur auf file Objekte zurück, oder?

Servus,

klassischer Fall von API-Doc:

http://java.sun.com/j2se/1.4.1/docs/api/

In der Klasse File gibt es die Methode delete(), die das aktuelle File oder Verzeichnis löscht. Das Verzeichnis muss leer sein.

Peter

oder zum kompletten löschen von ganzen Verzeichnissen mit Inhalten:

public class CFileUtils

{

/**

* Method nukeFolder.

* @param strFolderPath

* @throws IOException

*/

public static void nukeFolder(String strFolderPath) throws IOException

{

File objFile = new File (strFolderPath);

nukeFolder(objFile);

}

/**

* Method nukeFolder.

* @param objFolder

* @throws IOException

*/

public static void nukeFolder(File objFolder) throws IOException

{

nukeSubFolder(objFolder);

objFolder.delete();

}

/**

* Method makeSlashedPath.

* @param strPath

* @return String

*/

public static String makeSlashedPath(String strPath)

{

String strResultPath = strPath;

if ('\\' != strResultPath.charAt(strResultPath.length()-1))

{

strResultPath += "\\";

}

return strResultPath;

}

/**

* Method nukeSubFolder.

* @param path

* @throws IOException

*/

private static void nukeSubFolder(File path) throws IOException

{

File[] files = path.listFiles();

if (null != files)

{

for (int nIndex = 0; nIndex < files.length; ++nIndex)

{

if (files[nIndex].isDirectory())

{

nukeSubFolder(files[nIndex]);

}

files[nIndex].delete();

}

}

}

}

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.