NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


//import static dosyaokuma.deger;
import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;

public class dosyaokuma {

/**
* Kullanıcıdan Başlangıç Klasorunu, Ve Dosya Isminde Gececek Arama Değerini
* Alın Daha Sonra, Bu Arama Sonucuna Uyan Tüm Dosya Ve Klasorleri Belli Bir
* Formatta Listeleyin
*
* # Dosya Adı Türü Boyut 1 C:Usersaraba.txt Dosya 1152 2
* C:Userstestjava.txt Dosya 17824 3 C:Usersarchive Klasor 0
*/

public static Scanner oku = new Scanner(System.in);
public static String val = "";
public static ArrayList<File> rL = new ArrayList<>();
//public static String deger[] = new String[5];
// deger={"0","KB","MB","GB","TB"};
public static String[] deger = {"Byte","KB", "MB", "GB"};

public static void showSonuc() {
// Eğer Arama Sonucu Yoksa
if (rL.isEmpty()) {
System.out.println(
"İstenilen Kriterlerde Dosya Bulunamadı");
} else {


String f = "%3dt%-50st%6st%10dn";
// ArrayListte Toplanan Her Dosyayı
for (int i = 0; i < rL.size(); i++) {
File dosya = rL.get(i);
System.out.println("dsfsdgfdgdfgfdgfdgf"+dosya.getName().length());
if(dosya.length()<1024)
{
System.out.printf(
f,
(i + 1),
dosya.getName(),
(dosya.isFile() ? "Dosya" : "Klasor"),
dosya.length());
}else
{
double a=(double)dosya.length();
int cnt = 0;
while(a>1024)
{
a=a/1024;
cnt++;
}

String f1 = "%3dt%-50st%6st%10ft%10sn";
System.out.printf(
f1,
(i + 1),
dosya.getName(),
(dosya.isFile() ? "Dosya" : "Klasor"),
a,deger[cnt]);

}
}
}
}

/*
1 - Sonuc Listesinde Boyutlar
Büyüklüğe Göre Listenecek

1KB 1024 BYTE
1MB 1024 KB
1GB 1024 MB

2 - Eğer Sonuc Listesinde Gösterilecek Dosyanın
Tam Yol Uzunluğu 42 Karakterden Uzunsa
Dosyanın Adını, Kısaysa, Dosyanın Tam YOlunu
Göstereceksiniz

3 - Arama Sonucundaki File Instance'lari
Eğer Bir Dosyayı Gösteriyorsa
DOSYA (DOSYA UZANTISI) ŞEklinde Gösterilecek

a.txt Dosya (TXT)
Tast Klasor
Aqweasda.mp3 Dosya (MP3)
*/
public static void ara(File f) {
// Eğer f Bir Klasorse
if (f.isDirectory()) {
File altDosyalar[] = f.listFiles();

// kriterlere uyuyormu kontrol et
if(f.getName().contains(".txt") || f.getName().contains(".html")||f.getName().contains(".java")||f.getName().contains(".xml"))
{
if (f.getName().contains(val))
{
rL.add(f);
}
}
// AltDosyalar Arrayi, f'nin İçi Boşsa null Gelecektir
// Eğer Null Gelirse, Arrayi Dolaşamam
if (altDosyalar != null) {
// klasorun içindeki tüm dosyaları tekrar
// ara methoduna tek tek yolla
for (File altDosya : altDosyalar) {
ara(altDosya);
}
}
} // Eğer f bir dosya ise
else {
// kriterler uyuyormu kontrol et
if(f.getName().contains(".txt") || f.getName().contains(".html")||f.getName().contains(".java")||f.getName().contains(".xml"))
{
if (f.getName().contains(val))
{
rL.add(f);
}
}
}

}

public static void main(String[] args) {
System.out.print("Başlangıç Klasörü : ");
File f = new File(oku.next());
System.out.print("Aranacak Değer : ");
val = oku.next();

System.out.println("Arama Başlatıldı");
ara(f);
System.out.println("Arama Bitti");
showSonuc();

}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.