File tree Expand file tree Collapse file tree
src/main/java/ru/nsu/gunko/topic10/task3
src/main/java/ru/nsu/gunko/networking/task1
src/main/java/ru/nsu/gunko/topic7/task1
src/main/java/ru/nsu/gunko/topic8/task1
src/main/java/ru/nsu/gunko/topic9/task1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ target /
2+ ! .mvn /wrapper /maven-wrapper.jar
3+ ! ** /src /main /** /target /
4+ ! ** /src /test /** /target /
5+
6+ # ## IntelliJ IDEA ###
7+ .idea /modules.xml
8+ .idea /jarRepositories.xml
9+ .idea /compiler.xml
10+ .idea /libraries /
11+ * .iws
12+ * .iml
13+ * .ipr
14+
15+ # ## Eclipse ###
16+ .apt_generated
17+ .classpath
18+ .factorypath
19+ .project
20+ .settings
21+ .springBeans
22+ .sts4-cache
23+
24+ # ## NetBeans ###
25+ /nbproject /private /
26+ /nbbuild /
27+ /dist /
28+ /nbdist /
29+ /.nb-gradle /
30+ build /
31+ ! ** /src /main /** /build /
32+ ! ** /src /test /** /build /
33+
34+ # ## VS Code ###
35+ .vscode /
36+
37+ # ## Mac OS ###
38+ .DS_Store
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >ru.nsu.gunko.topic10.task3</groupId >
8+ <artifactId >main</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+
11+ <properties >
12+ <maven .compiler.source>21</maven .compiler.source>
13+ <maven .compiler.target>21</maven .compiler.target>
14+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
15+ </properties >
16+
17+ <dependencies >
18+ <dependency >
19+ <groupId >com.google.guava</groupId >
20+ <artifactId >guava</artifactId >
21+ <version >32.1.3-jre</version >
22+ </dependency >
23+ </dependencies >
24+
25+ <build >
26+ <plugins >
27+ <plugin >
28+ <artifactId >maven-assembly-plugin</artifactId >
29+ <configuration >
30+ <archive >
31+ <manifest >
32+ <mainClass >ru.nsu.gunko.topic10.task3.Main</mainClass >
33+ </manifest >
34+ </archive >
35+ <descriptorRefs >
36+ <descriptorRef >jar-with-dependencies</descriptorRef >
37+ </descriptorRefs >
38+ </configuration >
39+ </plugin >
40+ </plugins >
41+ </build >
42+
43+ </project >
Original file line number Diff line number Diff line change 1+ package ru .nsu .gunko .topic10 .task3 ;
2+
3+ import com .google .common .io .Files ;
4+
5+ import java .io .File ;
6+ import java .net .URI ;
7+
8+ public class Main {
9+ public static void main (String [] args ) {
10+ File root = new File (args [0 ]);
11+ URI base = root .toURI ();
12+
13+ for (File entry : Files .fileTraverser ().depthFirstPreOrder (root )) {
14+ String resName = new File (base .relativize (entry .toURI ()).getPath ()).getPath ();
15+ System .out .println (resName );
16+ }
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ target /
2+ ! .mvn /wrapper /maven-wrapper.jar
3+ ! ** /src /main /** /target /
4+ ! ** /src /test /** /target /
5+
6+ # ## IntelliJ IDEA ###
7+ .idea /modules.xml
8+ .idea /jarRepositories.xml
9+ .idea /compiler.xml
10+ .idea /libraries /
11+ * .iws
12+ * .iml
13+ * .ipr
14+
15+ # ## Eclipse ###
16+ .apt_generated
17+ .classpath
18+ .factorypath
19+ .project
20+ .settings
21+ .springBeans
22+ .sts4-cache
23+
24+ # ## NetBeans ###
25+ /nbproject /private /
26+ /nbbuild /
27+ /dist /
28+ /nbdist /
29+ /.nb-gradle /
30+ build /
31+ ! ** /src /main /** /build /
32+ ! ** /src /test /** /build /
33+
34+ # ## VS Code ###
35+ .vscode /
36+
37+ # ## Mac OS ###
38+ .DS_Store
Original file line number Diff line number Diff line change 1+ qwerty
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >ru.nsu.gunko.networking.task1</groupId >
8+ <artifactId >main</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+
11+ <properties >
12+ <maven .compiler.source>21</maven .compiler.source>
13+ <maven .compiler.target>21</maven .compiler.target>
14+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
15+ </properties >
16+
17+ </project >
Original file line number Diff line number Diff line change 1+ package ru .nsu .gunko .networking .task1 ;
2+
3+ public class Client {
4+
5+ public static void main (String [] args ) {
6+
7+ }
8+
9+ }
Original file line number Diff line number Diff line change 1+ package ru .nsu .gunko .networking .task1 ;
2+
3+ import java .io .*;
4+ import java .net .*;
5+
6+ public class Server {
7+
8+ public static void main (String [] args ) {
9+ String basePath = "/home/pyro/test" ;
10+
11+ try (ServerSocket serverSocket = new ServerSocket (8008 )) {
12+
13+ while (true ) {
14+
15+ try (Socket socket = serverSocket .accept ();
16+ BufferedReader request = new BufferedReader (new InputStreamReader (socket .getInputStream ()))) {
17+
18+ String lineOfRequest = request .readLine ();
19+ String [] parts = lineOfRequest .split (" " );
20+ String path = parts [1 ];
21+
22+ try (BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (socket .getOutputStream ()))) {
23+ File f = new File (basePath + path );
24+
25+ if (f .exists ()) {
26+ if (!f .isDirectory ()) {
27+ String line ;
28+
29+ try (BufferedReader reader = new BufferedReader (new FileReader (basePath + path ))) {
30+
31+ while ((line = reader .readLine ()) != null ) {
32+ writer .write (line + "\n " );
33+ writer .flush ();
34+ }
35+ }
36+
37+ } else {
38+ writer .write ("Is directory, replay request please" );
39+ }
40+
41+ } else {
42+ writer .write ("404: This not found\n " );
43+ }
44+
45+ }
46+
47+ }
48+
49+ }
50+
51+ } catch (IOException e ) {
52+ throw new RuntimeException (e );
53+ }
54+
55+ }
56+
57+ }
Original file line number Diff line number Diff line change 1+ target /
2+ ! .mvn /wrapper /maven-wrapper.jar
3+ ! ** /src /main /** /target /
4+ ! ** /src /test /** /target /
5+
6+ # ## IntelliJ IDEA ###
7+ .idea /modules.xml
8+ .idea /jarRepositories.xml
9+ .idea /compiler.xml
10+ .idea /libraries /
11+ * .iws
12+ * .iml
13+ * .ipr
14+
15+ # ## Eclipse ###
16+ .apt_generated
17+ .classpath
18+ .factorypath
19+ .project
20+ .settings
21+ .springBeans
22+ .sts4-cache
23+
24+ # ## NetBeans ###
25+ /nbproject /private /
26+ /nbbuild /
27+ /dist /
28+ /nbdist /
29+ /.nb-gradle /
30+ build /
31+ ! ** /src /main /** /build /
32+ ! ** /src /test /** /build /
33+
34+ # ## VS Code ###
35+ .vscode /
36+
37+ # ## Mac OS ###
38+ .DS_Store
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >ru.nsu.gunko.topic7.task1</groupId >
8+ <artifactId >topic7</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+
11+ <properties >
12+ <maven .compiler.source>21</maven .compiler.source>
13+ <maven .compiler.target>21</maven .compiler.target>
14+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
15+ </properties >
16+
17+ </project >
You can’t perform that action at this time.
0 commit comments