SlideShare a Scribd company logo
Язык Java




Объект File
  java.io
File
●   public static final char separatorChar
●   public static final String separator
●   public static final char pathSeparatorChar
●   public static final String pathSeparator
●   public File(String pathname)
●   public File(String parent, String child)
●   public File(File parent, String child)
●   public File(URI uri)
●   public String getName()
●   public String getParent()
●   public File getParentFile()
●   public String getPath()
●   public boolean isAbsolute()
●   public String getAbsolutePath()
●   public File getAbsoluteFile()
●   public String getCanonicalPath() throws IOException
●   public File getCanonicalFile() throws IOException
File (продолжение)
●   public boolean canRead()
●   public boolean canWrite()
●   public boolean exists()
●   public boolean isDirectory()
●   public boolean isFile()
●   public boolean isHidden()
●   public long lastModified()
●   public long length()
●   public boolean createNewFile() throws IOException
●   public boolean delete()
●   public String[] list()
●   public String[] list(FilenameFilter filter)
●   public File[] listFiles()
●   public File[] listFiles(FilenameFilter filter)
●   public File[] listFiles(FileFilter filter)
●   public boolean mkdir()
●   public boolean mkdirs()
●   public boolean renameTo(File dest)
File (продолжение)
●   public boolean setReadOnly()
●   public boolean setWritable(boolean writable, boolean
    ownerOnly)
●   public boolean setWritable(boolean writable)
●   public boolean setReadable(boolean readable, boolean
    ownerOnly)
●   public boolean setReadable(boolean readable)
●   public boolean setExecutable(boolean executable, boolean
    ownerOnly)
●   public boolean setExecutable(boolean executable)
●   public boolean canExecute()
●   public long getTotalSpace()
●   public long getFreeSpace()
●   public long getUsableSpace()
●   public static File createTempFile(String prefix, String suffix,
    File directory)
●   public static File createTempFile(String prefix, String suffix)
    throws IOException
Пример использования
●   private File f;
    private Date d;
    private File f1;
    public FileTestClass(String name, String name2)
    {
       f1=new File(name);
       d=new Date(f1.lastModified());
       f=new File(name2);
    }

    public String[] outAllFiles()
    {
      File[] fs=f.listFiles(new MyFilter(d));
      String[] ss=new String[fs.length];
      for(int i=0;i<fs.length;++i)
         ss[i]=fs[i].getPath();
      return ss;
    }
Интерфейс FileFilter
●   public interface FileFilter{
      boolean accept(File pathname);
    }
Пример использования

●   public class MyFilter implements FileFilter{
       private Date date;
       public MyFilter(Date date)
      {
          this.date=date;
       }

        public boolean accept(File pathname) {
          Date date1 = new Date(pathname.lastModified());
          return (date.getTime()>=date1.getTime());
        }
    }
Интерфейс FilanameFilter

●   interface FilenameFilter {
       boolean accept(File dir, String name);
    }
Работа со временем

●   class Date
    ●   public Date(long date)
●   class GregorianCalendar
    ●   public GregorianCalendar(int year, int month, int
        dayOfMonth, int hourOfDay, int minute, int second)
    ●   public final Date getTime()
    ●   public final void setTime(Date date)
Конец




            Вопросы
e-mail: a.bovanenko@gmail.com

More Related Content

ODP
ZIP, GZIP Streams in java
PDF
Infinum android talks_10_getting groovy on android
PDF
Swift 4 : Codable
PPTX
GopherCon Denver LT 2018
PDF
Laying Pipe with Transmogrifier
PPT
Oop lecture9 11
ODP
Migrations With Transmogrifier
PDF
Program to-copy-contents-of-one-file-to-another
ZIP, GZIP Streams in java
Infinum android talks_10_getting groovy on android
Swift 4 : Codable
GopherCon Denver LT 2018
Laying Pipe with Transmogrifier
Oop lecture9 11
Migrations With Transmogrifier
Program to-copy-contents-of-one-file-to-another

What's hot (14)

PDF
Migrating from drupal to plone with transmogrifier
DOCX
java copy file program
PDF
Geeks Anonymes - Le langage Go
PDF
Go破壊
PDF
Closures for Java
PDF
File input output in Java
PDF
C++ prgms io file unit 7
PDF
Workshop programs
PPTX
MessagePack - An efficient binary serialization format
PDF
Groovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume Laforge
PDF
Transmogrifier: Migrating to Plone with less pain
PPTX
Next Generation Language Go
PDF
Python for Mac Admins
ODP
Clojure made really really simple
Migrating from drupal to plone with transmogrifier
java copy file program
Geeks Anonymes - Le langage Go
Go破壊
Closures for Java
File input output in Java
C++ prgms io file unit 7
Workshop programs
MessagePack - An efficient binary serialization format
Groovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume Laforge
Transmogrifier: Migrating to Plone with less pain
Next Generation Language Go
Python for Mac Admins
Clojure made really really simple
Ad

Viewers also liked (7)

PDF
Vertical Roller Mill Gearbox Reduction Ratio Calculations
DOCX
Hydraulic system vertical roller mill operation
PPT
Clinker cooler's efficiency
PDF
Bag filters
PDF
Red river in clinker cooler
PPT
VRM
PDF
Vertical raw mill pradeep kumar
Vertical Roller Mill Gearbox Reduction Ratio Calculations
Hydraulic system vertical roller mill operation
Clinker cooler's efficiency
Bag filters
Red river in clinker cooler
VRM
Vertical raw mill pradeep kumar
Ad

Similar to File. Java (20)

PDF
Active Software Documentation using Soul and IntensiVE
PPSX
DIWE - File handling with PHP
PPT
From Java to Python
PDF
Lombokの紹介
PDF
import required package file import java.io.File; The Filed.pdf
PDF
Java Week4(A) Notepad
DOCX
Know how to redirect input and output- and know how to append to an ex.docx
PDF
My History
PDF
Refactoring In Tdd The Missing Part
PDF
File Handling in C Programming
PPTX
Various types of File Operations in Java
PDF
PDF
Module 03 File Handling in C
PPTX
Session 23 - JDBC
PPT
Oop lecture9 12
PPT
Chapter 5 Class File
PDF
Application-Specific Models and Pointcuts using a Logic Meta Language
PPTX
files.pptx
PDF
Files in c
PDF
Migrating existing Projects to Wonder
Active Software Documentation using Soul and IntensiVE
DIWE - File handling with PHP
From Java to Python
Lombokの紹介
import required package file import java.io.File; The Filed.pdf
Java Week4(A) Notepad
Know how to redirect input and output- and know how to append to an ex.docx
My History
Refactoring In Tdd The Missing Part
File Handling in C Programming
Various types of File Operations in Java
Module 03 File Handling in C
Session 23 - JDBC
Oop lecture9 12
Chapter 5 Class File
Application-Specific Models and Pointcuts using a Logic Meta Language
files.pptx
Files in c
Migrating existing Projects to Wonder

More from Alexey Bovanenko (20)

PDF
Python sqlite3
PDF
Python. re
PDF
python dict
PDF
Python. Строки
PDF
Python. Введение
PPT
PPT
Конвертация строковых данных в числовые
ODP
PPT
Обработка символов в языке C
ODP
PPTX
Javascript functions
PPTX
Javascript String object
PDF
Конструктор копирования
PDF
Tempale Intro
PDF
transaction. php
PDF
cookie. support by php
PDF
php sessions
ODP
Java IO. Streams
ODP
Regular Expressions
ODP
Classes: Number, String, StringBuffer, StringBuilder
Python sqlite3
Python. re
python dict
Python. Строки
Python. Введение
Конвертация строковых данных в числовые
Обработка символов в языке C
Javascript functions
Javascript String object
Конструктор копирования
Tempale Intro
transaction. php
cookie. support by php
php sessions
Java IO. Streams
Regular Expressions
Classes: Number, String, StringBuffer, StringBuilder

Recently uploaded (20)

PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Computing-Curriculum for Schools in Ghana
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
master seminar digital applications in india
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
RMMM.pdf make it easy to upload and study
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Updated Idioms and Phrasal Verbs in English subject
PDF
01-Introduction-to-Information-Management.pdf
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Supply Chain Operations Speaking Notes -ICLT Program
History, Philosophy and sociology of education (1).pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Computing-Curriculum for Schools in Ghana
UNIT III MENTAL HEALTH NURSING ASSESSMENT
master seminar digital applications in india
What if we spent less time fighting change, and more time building what’s rig...
RMMM.pdf make it easy to upload and study
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
202450812 BayCHI UCSC-SV 20250812 v17.pptx
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Weekly quiz Compilation Jan -July 25.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Orientation - ARALprogram of Deped to the Parents.pptx
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Updated Idioms and Phrasal Verbs in English subject
01-Introduction-to-Information-Management.pdf

File. Java

  • 2. File ● public static final char separatorChar ● public static final String separator ● public static final char pathSeparatorChar ● public static final String pathSeparator ● public File(String pathname) ● public File(String parent, String child) ● public File(File parent, String child) ● public File(URI uri) ● public String getName() ● public String getParent() ● public File getParentFile() ● public String getPath() ● public boolean isAbsolute() ● public String getAbsolutePath() ● public File getAbsoluteFile() ● public String getCanonicalPath() throws IOException ● public File getCanonicalFile() throws IOException
  • 3. File (продолжение) ● public boolean canRead() ● public boolean canWrite() ● public boolean exists() ● public boolean isDirectory() ● public boolean isFile() ● public boolean isHidden() ● public long lastModified() ● public long length() ● public boolean createNewFile() throws IOException ● public boolean delete() ● public String[] list() ● public String[] list(FilenameFilter filter) ● public File[] listFiles() ● public File[] listFiles(FilenameFilter filter) ● public File[] listFiles(FileFilter filter) ● public boolean mkdir() ● public boolean mkdirs() ● public boolean renameTo(File dest)
  • 4. File (продолжение) ● public boolean setReadOnly() ● public boolean setWritable(boolean writable, boolean ownerOnly) ● public boolean setWritable(boolean writable) ● public boolean setReadable(boolean readable, boolean ownerOnly) ● public boolean setReadable(boolean readable) ● public boolean setExecutable(boolean executable, boolean ownerOnly) ● public boolean setExecutable(boolean executable) ● public boolean canExecute() ● public long getTotalSpace() ● public long getFreeSpace() ● public long getUsableSpace() ● public static File createTempFile(String prefix, String suffix, File directory) ● public static File createTempFile(String prefix, String suffix) throws IOException
  • 5. Пример использования ● private File f; private Date d; private File f1; public FileTestClass(String name, String name2) { f1=new File(name); d=new Date(f1.lastModified()); f=new File(name2); } public String[] outAllFiles() { File[] fs=f.listFiles(new MyFilter(d)); String[] ss=new String[fs.length]; for(int i=0;i<fs.length;++i) ss[i]=fs[i].getPath(); return ss; }
  • 6. Интерфейс FileFilter ● public interface FileFilter{ boolean accept(File pathname); }
  • 7. Пример использования ● public class MyFilter implements FileFilter{ private Date date; public MyFilter(Date date) { this.date=date; } public boolean accept(File pathname) { Date date1 = new Date(pathname.lastModified()); return (date.getTime()>=date1.getTime()); } }
  • 8. Интерфейс FilanameFilter ● interface FilenameFilter { boolean accept(File dir, String name); }
  • 9. Работа со временем ● class Date ● public Date(long date) ● class GregorianCalendar ● public GregorianCalendar(int year, int month, int dayOfMonth, int hourOfDay, int minute, int second) ● public final Date getTime() ● public final void setTime(Date date)
  • 10. Конец Вопросы e-mail: a.bovanenko@gmail.com