SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler offline
Язык 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

Mais conteúdo relacionado

Mais procurados

Mais procurados (14)

Migrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifierMigrating from drupal to plone with transmogrifier
Migrating from drupal to plone with transmogrifier
 
java copy file program
java copy file programjava copy file program
java copy file program
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Go破壊
Go破壊Go破壊
Go破壊
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
 
File input output in Java
File input output in JavaFile input output in Java
File input output in Java
 
C++ prgms io file unit 7
C++ prgms io file unit 7C++ prgms io file unit 7
C++ prgms io file unit 7
 
Workshop programs
Workshop programsWorkshop programs
Workshop programs
 
MessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization formatMessagePack - An efficient binary serialization format
MessagePack - An efficient binary serialization format
 
Groovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume Laforge
Groovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume LaforgeGroovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume Laforge
Groovy Update, Groovy Ecosystem, and Gaelyk -- Devoxx 2010 -- Guillaume Laforge
 
Transmogrifier: Migrating to Plone with less pain
Transmogrifier: Migrating to Plone with less painTransmogrifier: Migrating to Plone with less pain
Transmogrifier: Migrating to Plone with less pain
 
Next Generation Language Go
Next Generation Language GoNext Generation Language Go
Next Generation Language Go
 
Python for Mac Admins
Python for Mac AdminsPython for Mac Admins
Python for Mac Admins
 
Clojure made really really simple
Clojure made really really simpleClojure made really really simple
Clojure made really really simple
 

Destaque (7)

Vertical Roller Mill Gearbox Reduction Ratio Calculations
Vertical Roller Mill Gearbox Reduction Ratio CalculationsVertical Roller Mill Gearbox Reduction Ratio Calculations
Vertical Roller Mill Gearbox Reduction Ratio Calculations
 
Hydraulic system vertical roller mill operation
Hydraulic system vertical roller mill operationHydraulic system vertical roller mill operation
Hydraulic system vertical roller mill operation
 
Clinker cooler's efficiency
Clinker cooler's efficiencyClinker cooler's efficiency
Clinker cooler's efficiency
 
Bag filters
Bag filtersBag filters
Bag filters
 
Red river in clinker cooler
Red river in clinker  coolerRed river in clinker  cooler
Red river in clinker cooler
 
VRM
VRMVRM
VRM
 
Vertical raw mill pradeep kumar
Vertical raw mill pradeep kumarVertical raw mill pradeep kumar
Vertical raw mill pradeep kumar
 

Semelhante a File. Java

Active Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVEActive Software Documentation using Soul and IntensiVE
Active Software Documentation using Soul and IntensiVE
kim.mens
 
import required package file import java.io.File; The Filed.pdf
 import required package file import java.io.File; The Filed.pdf import required package file import java.io.File; The Filed.pdf
import required package file import java.io.File; The Filed.pdf
anandinternational01
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
Gabriele Lana
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
WO Community
 

Semelhante a File. Java (20)

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

Mais de Alexey Bovanenko

Mais de Alexey Bovanenko (20)

Python sqlite3
Python sqlite3Python sqlite3
Python sqlite3
 
Python. re
Python. rePython. re
Python. re
 
python dict
python dictpython dict
python dict
 
Python. Строки
Python. СтрокиPython. Строки
Python. Строки
 
Python. Введение
Python. ВведениеPython. Введение
Python. Введение
 
Nio java
Nio javaNio java
Nio java
 
Конвертация строковых данных в числовые
Конвертация строковых данных в числовыеКонвертация строковых данных в числовые
Конвертация строковых данных в числовые
 
Assert c
Assert cAssert c
Assert c
 
Обработка символов в языке C
Обработка символов в языке CОбработка символов в языке C
Обработка символов в языке C
 
System c
System cSystem c
System c
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
Javascript String object
Javascript String objectJavascript String object
Javascript String object
 
Конструктор копирования
Конструктор копированияКонструктор копирования
Конструктор копирования
 
Tempale Intro
Tempale IntroTempale Intro
Tempale Intro
 
transaction. php
transaction. phptransaction. php
transaction. php
 
cookie. support by php
cookie. support by phpcookie. support by php
cookie. support by php
 
php sessions
php sessionsphp sessions
php sessions
 
Java IO. Streams
Java IO. StreamsJava IO. Streams
Java IO. Streams
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Classes: Number, String, StringBuffer, StringBuilder
Classes: Number, String, StringBuffer, StringBuilderClasses: Number, String, StringBuffer, StringBuilder
Classes: Number, String, StringBuffer, StringBuilder
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 

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