Как сохранить файл в intellij idea
Перейти к содержимому

Как сохранить файл в intellij idea

  • автор:

Save projects as templates

If you have a project that you want to reproduce when creating new projects, you can save it as a custom project template. The IDE recreates the project tree with files and folders, build configurations, libraries, SDKs, and language level settings.

IntelliJ IDEA saves all project settings from the .idea folder to the template. So if you want your new projects to have some predefined run/debug configurations, select the Store as project file checkbox in these configurations before you save the template.

Save a project as a template

Saving a project as a template

  1. In the main menu, go to File | New Projects Setup | Save Project as Template .
  2. In the dialog that opens, name the template and configure the options:
    • Save : if the project contains more than one module, select whether you want to create a template from the whole project or from one of the modules. Otherwise, this option is not available.
    • Description : you can use the and , and and tags for formatting.
    • Replace parameters with placeholders (recommended): select another base Java package and another application server when creating a new template-based project or module. This option doesn’t allow you to add your custom parameters to a project.

Templates are saved to the projectTemplates folder in the IDE configuration directory.

Create a project from a template

Creating a project from a custom template

  1. Click New Project on the Welcome screen or select File | New Project from the main menu.
  2. In the dialog that opens, click the required template in the Templates section on the left.

Delete project templates

  1. In the main menu, go to File | New Projects Setup | Manage Project Templates .
  2. Select the template that you want to remove and click Remove .

Upload and download files

IntelliJ IDEA provides the following two ways to upload project files and folders to deployment servers:

  • Manually , at any time through a menu command.
  • Automatically , every time a file is updated, or before starting a debugging session, or during a commit to your version control system.

To mitigate the risk of temporary data loss during upload of new versions of existing files, IntelliJ IDEA can store the contents of the uploaded file under a temporary name, and only rename it back after the upload operation has been successfully completed.

To enable this option, go to Settings ( Ctrl+Alt+S ) |Build, Execution, Deployment | Deployment | Options and select the Use a temporary file during upload checkbox.

For downloading files and folders, IntelliJ IDEA supports only the manual mode.

IntelliJ IDEA shows the logs in the File Transfer tool window ( View | Tool Windows | File Transfer ).

File Transfer tool window

Enable the FTP/SFTP/WebDAV Connectivity plugin

This functionality relies on the FTP/SFTP/WebDAV Connectivity plugin, which is bundled and enabled in IntelliJ IDEA by default. If the relevant features aren’t available, make sure that you didn’t disable the plugin.

The FTP/SFTP/WebDAV Connectivity plugin is not available in IntelliJ IDEA Community Edition.

  1. Press Ctrl+Alt+S to open the IDE settings and then select Plugins .
  2. Open the Installed tab, find the FTP/SFTP/WebDAV Connectivity plugin, and select the checkbox next to the plugin name.

Upload a file or folder manually

Upload file or folder manually

  • In the Project tool window ( Alt+1 ), right-click a file or folder, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list. If the default server or server group is appointed, you can also select Upload to .

Upload locally changed files

  1. Switch to the Changes view ( Alt+0 ) to view the locally changed files.
  2. Right-click a file, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list. If the default server or server group group is appointed, you can also select Upload to .

Upload files after synchronizing with a VCS repository

  1. Synchronize the contents of your local files with the VCS repository by pressing Ctrl+T or selecting VCS | | Update from the main menu.
  2. Switch to the Update Info tab of the Version Control tool window Alt+9 .
  3. Right-click a file, then select Deployment | Upload to from the context menu, and choose the target deployment server or server group from the list. If the default server or server group is appointed, you can also select Upload to .

Upload checked-in files immediately after commit

Upload files from after commit area

  1. In the Changes view ( Alt+0 ), click to open the commit setting context menu.
  2. In the After Commit area of the menu, choose the target server or server group from the Upload files to list. Choose one of the existing configurations or create a new one: click and configure access to the relevant server, or set up a server group in the dialog that opens. To have your selection applied automatically in the future, select the Always use selected server or group of servers checkbox.
  3. Proceed with committing your changes.

Configure automatic upload of changed files to the default server or server group

IntelliJ IDEA considers a local file changed as soon as it is saved either automatically or manually ( File | Save All or Ctrl+S ), see Save and revert changes. Changed files can be automatically uploaded only to the default deployment server.

  1. Open the Options dialog by doing one of the following:
    • Go to Tools | Deployment | Options .
    • In the Settings dialog ( Ctrl+Alt+S ) , go to Build, Execution, Deployment | Deployment | Options .
  2. From the Upload changed files automatically to the default server list, choose when you want IntelliJ IDEA to upload changed files:
    • To upload any manually or automatically saved file, choose Always .
    • To upload only manually saved files, choose On explicit save action .
    • To suppress automatic upload, choose Never .
  3. If you enabled automatic upload, optionally configure the scope it should apply to:
    • Select Skip external changes to exclude local changes that were made using a third-party tool (a VCS, a script, and so on) from automatic upload.
    • Select Delete remote files when local are deleted to have IntelliJ IDEA automatically delete remote files during automatic uploads in case the local ones are deleted. Note that this option serves as an extra safety measure and may result in unwanted files remaining on the remote server. As an example, consider a local file Foo.php , which is renamed to Bar.php . Since renaming a file is technically indistinguishable from deleting the file and creating a new one, the following will happen after automatic upload:
      • If the option is enabled, the remote server will only contain Bar.php .
      • If the option is disabled, the remote server will contain both Foo.php and Bar.php after automatic upload. You will probably need to delete Foo.php manually afterwards.

Enabling the Upload changed files automatically to the default server option also enables Upload to default server in Settings | Tools | Actions on Save .

Download a file or folder

Download a file or folder

  1. In the main menu, go to Tools | Deployment | Browse Remote Host .
  2. In the Remote Host tool window that opens, select the required file or folder and choose Download from here from the context menu of the selection.

Download a file from the default deployment server

  • In the main menu, go to Tools | Deployment | Download from . IntelliJ IDEA will prompt you to overwrite local files, if any.

Путь к файлам в intellij Idea

введите сюда описание изображения

Два важных вопроса. Относительно чего вы указываете относительный путь и почему? Почему вам не похдодит абсолютный путь?

5 дек 2021 в 15:32

мне нужно будет скинуть проект на проверку, и при абсолютном пути считывание из файла будет выдавать ошибку в другой системе

5 дек 2021 в 15:37
Это понятный ответ только на один из вопросов.
5 дек 2021 в 15:39

при указании абсолютного пути, это не будет срабатывать верно на другой системе, именно поэтому мне и нужен относительный

5 дек 2021 в 15:44
относительно названия проекта
5 дек 2021 в 16:04

2 ответа 2

Сортировка: Сброс на вариант по умолчанию

Корневым путем в вашем случае является D:/Task1 , добавляя ../ вы отправляете сканер искать в родительской директории, т.е. в D: — естественно, путь некорректный. Для смещения относительно корневого каталога вниз используйте одну точку ./ , тогда поиск будет выполнен из D:/Task1 :

Scanner scanner = new Scanner(new File("./src/main/resources/input.txt")); 

Отслеживать
ответ дан 5 дек 2021 в 10:26
Yuriy Tsarkov Yuriy Tsarkov
101 2 2 бронзовых знака
когда я указываю такой путь, система все равно не может найти файл
5 дек 2021 в 13:42

нажми правой кнопкой мыши на нужной папке в структуре проекта
и выбери пункт Copy Path.

введите сюда описание изображения

введите сюда описание изображения

и в появившемся меню выбери нужное.

введите сюда описание изображения

если надо на диске узнать путь к файлу.
находим файл и жмём правой кнопкой мыши на нужном файле, в меню выбираем свойство
во вкладке безопасность копируем путь.

 //в корне File file = new File("input.txt"); //в нужной папке File file2 = new File("/src/main/resources/input.txt"); System.out.println(file.exists()); // файл существует? System.out.println(file2.exists()); // файл существует? System.out.println(file.createNewFile()); // файл создался? System.out.println(file2.createNewFile()); // файл создался? 

Как сохранить проект с программы IntelliJ IDEA на компьютер?

Здравствуйте!
Мне надо отправить проект человеку. Подскажите пожалуйста, как сохранить проект с программы IntelliJ IDEA к себе на компьютер? А то только вижу Save all, а куда надо нажать чтоб сохранить к себе на рабочий стол, не понимаю..
Заранее спасибо!

  • Вопрос задан более трёх лет назад
  • 15730 просмотров

1 комментарий

Простой 1 комментарий

longclaps

На стул сохраняй, так надёжнее ) Шутка. Сохраняй в рабочую директорию IntelliJ IDEA.

Решения вопроса 1

Сергей Горностаев @sergey-gornostaev Куратор тега Java

Седой и строгий

5da2a036a1603345396118.png

Вы думаете, что IDEA открывает проекты откуда-то из Интернета? Проект уже на вашем компьютере.

Достаточно открыть каталог проводником или другим файловым менеджером и можете хоть сначала копировать, хоть сразу архивировать и отправлять.

Ответ написан более трёх лет назад

Комментировать

Нравится 1 Комментировать

Ответы на вопрос 0

Ваш ответ на вопрос

Войдите, чтобы написать ответ

mysql

  • MySQL
  • +2 ещё

Как пофиксить дедлоки и таймауты во время транзакций сохранения данных в базу при многопоточности от ForkJoinPool?

  • 1 подписчик
  • вчера
  • 159 просмотров

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *