Skip to content

Commit

Permalink
v1.0.2
Browse files Browse the repository at this point in the history
some changes
  • Loading branch information
Lion6477 committed Jan 28, 2024
1 parent 96b5760 commit 6a6f578
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 87 deletions.
136 changes: 68 additions & 68 deletions .idea/artifacts/FileSorter_jar.xml

Large diffs are not rendered by default.

Binary file removed out/artifacts/FileSorter_jar/FileSorter.jar
Binary file not shown.
34 changes: 27 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@

<groupId>ua.skushnerov</groupId>
<artifactId>FileSorter</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
<name>FileSorter</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -47,12 +47,32 @@
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
</execution>
</executions>
<configuration>
<mainClass>ua.skushnerov.FileSorterApp</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>

</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
requires javafx.graphics;
requires javafx.fxml;

opens ua.skushnerov; // Экспорт пакета org.example
opens ua.skushnerov;
opens ua.skushnerov.controller to javafx.fxml;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// limitations under the License.
package ua.skushnerov;

public class Launcher {
public class App {
public static void main(String[] args) {
FileSorterApp.main(args);
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/ua/skushnerov/FileSorterApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public void start(Stage primaryStage) throws Exception {
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("/fxml/fileSorter.fxml"));
Parent root = fxmlLoader.load();
FileSorterController controller = fxmlLoader.getController();

primaryStage.setTitle("File Sorter");
// primaryStage.setScene(new Scene(root, 280, 170));
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/ua/skushnerov/service/Sorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;

Expand All @@ -24,23 +25,17 @@ public static void sortFilesByExtension(String directoryPath) {
File directory = new File(directoryPath);
File[] files = directory.listFiles();

// Структура для хранения файлов по расширению
HashMap<String, List<File>> fileMap = new HashMap<>();

// Группировка файлов по расширению
for (File file : files) {
if (file.isFile()) {
String extension = getFileExtension(file);
fileMap.computeIfAbsent(extension, k -> new ArrayList<>()).add(file);
}
}

// Сортировка файлов внутри каждой группы
fileMap.forEach((extension, fileList) -> {
fileList.sort((f1, f2) -> f1.getName().compareTo(f2.getName()));
});
fileMap.forEach((extension, fileList) -> fileList.sort(Comparator.comparing(File::getName)));

// Перемещение файлов в новые каталоги
for (String extension : fileMap.keySet()) {
File extensionDirectory = new File(directoryPath + "/" + extension);
if (!extensionDirectory.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: ua.skushnerov.Launcher
Main-Class: ua.skushnerov.App

0 comments on commit 6a6f578

Please sign in to comment.