У вас большие запросы!
Точнее, от вашего браузера их поступает слишком много, и сервер VK забил тревогу.
Эта страница была загружена по HTTP, вместо безопасного HTTPS, а значит телепортации обратно не будет.
Обратитесь в поддержку сервиса.
Вы отключили сохранение Cookies, а они нужны, чтобы решить проблему.
Почему-то страница не получила всех данных, а без них она не работает.
Обратитесь в поддержку сервиса.
Вы вернётесь на предыдущую страницу через 5 секунд.
Вернуться назад
Java File Class
The File class is an abstract representation of file and directory pathname. A pathname can be either absolute or relative.
The File class have several methods for working with directories and files such as creating new directories or files, deleting and renaming directories or files, listing the contents of a directory etc.
Fields
| Modifier | Type | Field | Description |
|---|---|---|---|
| static | String | pathSeparator | It is system-dependent path-separator character, represented as a string for convenience. |
| static | char | pathSeparatorChar | It is system-dependent path-separator character. |
| static | String | separator | It is system-dependent default name-separator character, represented as a string for convenience. |
| static | char | separatorChar | It is system-dependent default name-separator character. |
Constructors
| Constructor | Description |
|---|---|
| File(File parent, String child) | It creates a new File instance from a parent abstract pathname and a child pathname string. |
| File(String pathname) | It creates a new File instance by converting the given pathname string into an abstract pathname. |
| File(String parent, String child) | It creates a new File instance from a parent pathname string and a child pathname string. |
| File(URI uri) | It creates a new File instance by converting the given file: URI into an abstract pathname. |
Useful Methods
| Modifier and Type | Method | Description |
|---|---|---|
| static File | createTempFile(String prefix, String suffix) | It creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name. |
| boolean | createNewFile() | It atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. |
| boolean | canWrite() | It tests whether the application can modify the file denoted by this abstract pathname.String[] |
| boolean | canExecute() | It tests whether the application can execute the file denoted by this abstract pathname. |
| boolean | canRead() | It tests whether the application can read the file denoted by this abstract pathname. |
| boolean | isAbsolute() | It tests whether this abstract pathname is absolute. |
| boolean | isDirectory() | It tests whether the file denoted by this abstract pathname is a directory. |
| boolean | isFile() | It tests whether the file denoted by this abstract pathname is a normal file. |
| String | getName() | It returns the name of the file or directory denoted by this abstract pathname. |
| String | getParent() | It returns the pathname string of this abstract pathname’s parent, or null if this pathname does not name a parent directory. |
| Path | toPath() | It returns a java.nio.file.Path object constructed from the this abstract path. |
| URI | toURI() | It constructs a file: URI that represents this abstract pathname. |
| File[] | listFiles() | It returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname |
| long | getFreeSpace() | It returns the number of unallocated bytes in the partition named by this abstract path name. |
| String[] | list(FilenameFilter filter) | It returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. |
| boolean | mkdir() | It creates the directory named by this abstract pathname. |
Java File Example 1
New File is created!
Java File Example 2
testFile1.txt /home/Work/Project/File/testFile1.txt true /home/Work/Project/File/testFile1.txt Exists? true
Java File Example 3
"info.properties" "info.properties".rtf .DS_Store .localized Alok news apache-tomcat-9.0.0.M19 apache-tomcat-9.0.0.M19.tar bestreturn_org.rtf BIODATA.pages BIODATA.pdf BIODATA.png struts2jars.zip workspace
Java File Example 4
"info.properties" Can Write: true Is Hidden: false Length: 15 bytes "info.properties".rtf Can Write: true Is Hidden: false Length: 385 bytes .DS_Store Can Write: true Is Hidden: true Length: 36868 bytes .localized Can Write: true Is Hidden: true Length: 0 bytes Alok news Can Write: true Is Hidden: false Length: 850 bytes apache-tomcat-9.0.0.M19 Can Write: true Is Hidden: false Length: 476 bytes apache-tomcat-9.0.0.M19.tar Can Write: true Is Hidden: false Length: 13711360 bytes bestreturn_org.rtf Can Write: true Is Hidden: false Length: 389 bytes BIODATA.pages Can Write: true Is Hidden: false Length: 707985 bytes BIODATA.pdf Can Write: true Is Hidden: false Length: 69681 bytes BIODATA.png Can Write: true Is Hidden: false Length: 282125 bytes workspace Can Write: true Is Hidden: false Length: 1972 bytes
Next Topic Java FileDescriptor

For Videos Join Our Youtube Channel: Join Now
Feedback
- Send your Feedback to [email protected]
Help Others, Please Share

Learn Latest Tutorials
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Python Design Patterns
![]()
![]()
![]()
Preparation




Trending Technologies
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
B.Tech / MCA
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Javatpoint Services
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
- Website Designing
- Website Development
- Java Development
- PHP Development
- WordPress
- Graphic Designing
- Logo
- Digital Marketing
- On Page and Off Page SEO
- PPC
- Content Development
- Corporate Training
- Classroom and Online Training
- Data Entry
Training For College Campus
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week
Like/Subscribe us for latest updates or newsletter

Как открыть файл или папку из java-приложения?
Каким образом можно открыть файл или папку, как будто мы открываем его через стандартный файловый браузер / Finder / и т.д.
Отслеживать
1,473 10 10 серебряных знаков 16 16 бронзовых знаков
задан 24 янв 2011 в 20:07
8,677 18 18 золотых знаков 74 74 серебряных знака 181 181 бронзовый знак
Сформулируйте, пожалуйста, точнее. Не вполне понятно, чего надо сделать-то…
24 янв 2011 в 20:10
Могу предложить варианты: а) Вам нужен диалог открытия файла? б) Вы хотите сэмулировать двойноё щелчёк по файлу в оболочке? Т.е. чтоыб он открылся так, будто юзер по нему дважды щёлкнул?
24 янв 2011 в 20:13
Например: у нас есть картинка и к ней в ОС привязан стандартный Windows Picture and Fax Viewer. Нужно из java-приложения запустить этот самый Viewer с открытой в нем картинкой. 🙂
Открыть файл при помощи Java-программы, и получить Path этого файла
Что бы вопрос был понятнее, приведу аналогию: Когда тыкаешь по txt файлу открывается блокнот с содержимым файла, если конечно не другое приложение стоит, а я как раз вместо блокнота хочу подставить свою скомпилированную* программу *Лучше конечно с jar, но можно и с exe Цель такова: Сделать так, что бы при нажатии по файлу с определенным расширением (например txt), открывался JFrame с текстом из этого файла (по которому кликнули) Создавать JFrame и читать файли по Path, я умею, но как узнать path этого файла? Если вообще нет вариантов, то можно вот есть с bat файлом (Спасибо Akina): Создаём где-нибудь файл, называем его myfile.myext . Создаём где-нибудь bat-файл, называем его mybatch.bat . Редактируем bat-файл, пишем в него:
start javaw -jar Java_Program.jar %1
ПКМ по файлу >> Открыть с помощью >> Другие приложения >> bat-файл с программой Path будет поступать в String[] у метода main Пример кода для проверки:
public static void main(String[] args) < for (String string : args) < JOptionPane.showMessageDialog(null, string); >JOptionPane.showMessageDialog(null, "End"); >
Отслеживать
задан 11 янв 2021 в 11:28
981 1 1 золотой знак 5 5 серебряных знаков 19 19 бронзовых знаков
Используйте системное «Открыть с помощью» и поставьте галку «Всегда использовать эту программу». Первым параметром программе передаётся полное имя файла, с путём и прочими причиндалами. Если надо — в реестре можно подрихтовать строку запуска. PS. Настоятельно не рекомендую изменять существующие ассоциации — лучше изобретите собственное расширение.
11 янв 2021 в 11:32
Это-то я умею, но цель-то получить Path файла, который открыли при помощи моей программы
11 янв 2021 в 11:54
Я ж вроде сказал, что программе будет передано полное имя файла, с диском и путём. Вот и вытащи его из параметров.