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.

Frage zu Dateinen löschen

Empfohlene Antworten

Guten Morgen,

Kann mir bitte einer sagen, warum er die Datei nicht bei jedem Durchlauf löscht?


import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;

public class Entfernen implements ActionListener
{
String m = "0";
String h = "1";
String er = "2";
String tre = " [,]= [,]";
String strim;
String strih;
String strie;
String fm = "modus.properties";
String fh = "handbuch.properties";
String fe = "ergebnistyp.properties";
static Vector ventf = new Vector();

public void actionPerformed(ActionEvent e)
{
String inhalt = "" + PropertyGui.auswahlcmb.getSelectedIndex();

if (inhalt.equals(m))
{
File dateim = new File(fm);
if(dateim.exists())
{
dateim.delete();
modusentf();
}
else
{
modusentf();
}
}
else
{
if (inhalt.equals(h))
{
File dateih = new File(fh);
if(dateih.exists())
{
dateih.delete();
handbuchentf();
}
else
{
handbuchentf();
}
}
else
{
if (inhalt.equals(er))
{
File dateie = new File(fe);
if(dateie.exists())
{
dateie.delete();
ergebnistypentf();
}
else
{
ergebnistypentf();
}
}
else
{
System.out.println("Es wurde keine Datei gefunden");
}
}
}
}
public void modusentf()
{
try
{
int i = Tabelle.table.getSelectedRow();
ventf.remove(ventf.get(i));
}
catch(ArrayIndexOutOfBoundsException aioobe)
{
System.out.println("Es ist nichts makiert, um es entfernen zu können!");
}

Enumeration enum = ventf.elements();

while(enum.hasMoreElements())
{
String au = "" + enum.nextElement();
StringTokenizer st = new StringTokenizer(au,tre);

while (st.hasMoreTokens())
{
strim = "" + st.nextToken() + "=" + st.nextToken() + "\r\n";
}

try
{
RandomAccessFile output = new RandomAccessFile(fm,"rw");
output.seek(output.length());
output.write(strim.getBytes());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
}

public void handbuchentf()
{
try
{
int i = Tabelle.table.getSelectedRow();
ventf.remove(ventf.get(i));
}
catch(ArrayIndexOutOfBoundsException aioobe)
{
System.out.println("Es ist nichts makiert, um es entfernen zu können!");
}

Enumeration enum = ventf.elements();

while(enum.hasMoreElements())
{
String au = "" + enum.nextElement();
StringTokenizer st = new StringTokenizer(au,tre);

while (st.hasMoreTokens())
{
strih = "" + st.nextToken() + "=" + st.nextToken() + "\r\n";
}

try
{
RandomAccessFile output = new RandomAccessFile(fh,"rw");
output.seek(output.length());
output.write(strih.getBytes());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
}

public void ergebnistypentf()
{
try
{
int i = Tabelle.table.getSelectedRow();
ventf.remove(ventf.get(i));
}
catch(ArrayIndexOutOfBoundsException aioobe)
{
System.out.println("Es ist nichts makiert, um es entfernen zu können!");
}

Enumeration enum = ventf.elements();

while(enum.hasMoreElements())
{
String au = "" + enum.nextElement();
StringTokenizer st = new StringTokenizer(au,tre);

while (st.hasMoreTokens())
{
strie = "" + st.nextToken() + "=" + st.nextToken() + "\r\n";
}

try
{
RandomAccessFile output = new RandomAccessFile(fe,"rw");
output.seek(output.length());
output.write(strie.getBytes());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
}
}
}
[/PHP]

Hat sich erledigt.

Habe den .close() Befehl vergessen und eine offene Datei kann man nicht löschen.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

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.