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.

Größe einer datei

Empfohlene Antworten

Veröffentlicht

Ich hab versucht mir die größe einer datei anzeigen zu lassen

Code:

import java.io.*;

public class groesse

{

public static void main(String[] args)

{

String mails[] = new File("/var/mail/").list();

for (int i=0;i<mails.length;i++)

System.out.println(mails+"->"+mails.length());

}

}

aber mails.length() sagt teilweise dass die datei 8 groß sei....

aber wenn man im linux nachschaut ist die datei 0 kb groß,und ist vollkommen leer

muß man sich die größe einer datei anders anzeigen lassen?!?!?

Die Länge ist die Anzahl der Bytes.

Ich denke mal, dass schon durch das Vorhandensein einer Datei Speicher

belegt wird - das werden wohl die 8 Byte sein, die du angesprochen hast!?

Verbessert mich, falls es falsch gedacht ist!

Du lässt dir nicht die Größe einer Datei ausgeben, sondern die Länge der Datei- oder Ordnernamen eines Ordners.

Gruß Jaraz

hi!

Jaraz hat vollkommen recht da du die Länge des Strings ausgibst!!

probiers mal so:



import java.io.*;


public class groesse

{

public static void main(String[] args) 

{

File mails[] = new File("/var/mail/").listFiles();

for (int i=0;i<mails.length;i++)

System.out.println(mails[i]+"->"+mails[i].length());


}

}

Gruß

Azrael

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.