Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jvstd1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
jvstd1
Commits
393cd276
Commit
393cd276
authored
Oct 15, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
numerowanie Pana Tadeusza
parent
60ed6143
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
PT_Numeruj1.java
src/main/java/p16_pliki/PT_Numeruj1.java
+22
-0
PT_Numeruj2.java
src/main/java/p16_pliki/PT_Numeruj2.java
+26
-0
No files found.
src/main/java/p16_pliki/PT_Numeruj1.java
0 → 100644
View file @
393cd276
package
p16_pliki
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.util.Scanner
;
// v1: wypisz na ekran całęgo Pana Tadeusza numerując linie
public
class
PT_Numeruj1
{
public
static
void
main
(
String
[]
args
)
{
try
(
Scanner
scanner
=
new
Scanner
(
new
File
(
"pliki/pan_tadeusz.txt"
)))
{
int
nr
=
0
;
while
(
scanner
.
hasNextLine
())
{
String
line
=
scanner
.
nextLine
();
System
.
out
.
println
(++
nr
+
": "
+
line
);
}
System
.
out
.
println
(
"Łącznie wszystkich linii: "
+
nr
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
src/main/java/p16_pliki/PT_Numeruj2.java
0 → 100644
View file @
393cd276
package
p16_pliki
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.PrintWriter
;
import
java.util.Scanner
;
// v2: zapisuj ponumerowane linie do nowego pliku; pomijaj puste linie
public
class
PT_Numeruj2
{
public
static
void
main
(
String
[]
args
)
{
try
(
Scanner
scanner
=
new
Scanner
(
new
File
(
"pliki/pan_tadeusz.txt"
));
PrintWriter
out
=
new
PrintWriter
(
"out/ponumerowany.txt"
))
{
int
nr
=
0
;
while
(
scanner
.
hasNextLine
())
{
String
line
=
scanner
.
nextLine
();
if
(!
line
.
isEmpty
())
{
out
.
println
(++
nr
+
": "
+
line
);
}
}
System
.
out
.
println
(
"Łącznie niepustych linii: "
+
nr
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment