SlideShare a Scribd company logo
in.txt ( Suppose if we store the text file in D:Drive then the path of the file pointing to this file is
D:in.txt )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
3
38
39
40
41
42
43
44
45
46
45
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
___________________________________________________________________
ReadFile.java
import java.io.*;
import java.util.*;
public class ReadFile {
public static void main(String[] args) {
//Creating the Scanner class reference.
Scanner scanner=null;
try {
//Creating Scanner object by passing the file Object as input
scanner = new Scanner(new File("D:in.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//Creating the ArrayList Obkect
ArrayList integers = new ArrayList();
while (scanner.hasNext()) {
if (scanner.hasNextInt()) {
//Adding each element in the file to the ArrayList.
integers.add(scanner.nextInt());
}
}
//Create the Iterator Object.
Iterator i=integers.iterator();
//Iterator over the ArrayList
while(i.hasNext())
{
//Displaying the contents in the ArrayList.
System.out.println(i.next());
}
}
}
______________________________________________________________________
Output:
Enter File Name :D:in.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
3
38
39
40
41
42
43
44
45
46
4
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
_____________________________________________________________________
Solution
in.txt ( Suppose if we store the text file in D:Drive then the path of the file pointing to this file is
D:in.txt )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
3
38
39
40
41
42
43
44
45
46
45
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
___________________________________________________________________
ReadFile.java
import java.io.*;
import java.util.*;
public class ReadFile {
public static void main(String[] args) {
//Creating the Scanner class reference.
Scanner scanner=null;
try {
//Creating Scanner object by passing the file Object as input
scanner = new Scanner(new File("D:in.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//Creating the ArrayList Obkect
ArrayList integers = new ArrayList();
while (scanner.hasNext()) {
if (scanner.hasNextInt()) {
//Adding each element in the file to the ArrayList.
integers.add(scanner.nextInt());
}
}
//Create the Iterator Object.
Iterator i=integers.iterator();
//Iterator over the ArrayList
while(i.hasNext())
{
//Displaying the contents in the ArrayList.
System.out.println(i.next());
}
}
}
______________________________________________________________________
Output:
Enter File Name :D:in.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
3
38
39
40
41
42
43
44
45
46
4
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
_____________________________________________________________________

More Related Content

PDF
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
DOCX
Please complete all the code as per instructions in Java programming.docx
PDF
Write a program that asks the user for the name of a file. The progr.pdf
PPTX
Random Class & File Handling.pptx
PDF
For the following I have finished most of this question but am havin.pdf
PDF
Objectives In this lab you will review passing arrays to methods and.pdf
PDF
Change the code in Writer.java only to get it working. Must contain .pdf
PDF
Simple Java Program for beginner with easy method.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
Please complete all the code as per instructions in Java programming.docx
Write a program that asks the user for the name of a file. The progr.pdf
Random Class & File Handling.pptx
For the following I have finished most of this question but am havin.pdf
Objectives In this lab you will review passing arrays to methods and.pdf
Change the code in Writer.java only to get it working. Must contain .pdf
Simple Java Program for beginner with easy method.pdf

Similar to in.txt ( Suppose if we store the text file in DDrive then the path .pdf (20)

PDF
Need help with this java code. fill in lines where needed. Also, not.pdf
PDF
OrderTest.javapublic class OrderTest {       Get an arra.pdf
PDF
I need help with this code working Create another project and add yo.pdf
PDF
So I have this code(StackInAllSocks) and I implemented the method but.pdf
DOCX
Array list
PDF
i am finishing a project for my cs 0401 java course. I have complete.pdf
PPT
Chapter 12 - File Input and Output
PPT
Java căn bản - Chapter12
PDF
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
PPT
Oop lecture9 11
PPTX
chapter 2(IO and stream)/chapter 2, IO and stream
PDF
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
PPTX
File Handlingb in java. A brief presentation on file handling
DOCX
Java Practical1 based on Basic assignment
PDF
Java programs
PDF
[10] Write a Java application which first reads data from the phoneb.pdf
PDF
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
PDF
Simple 27 Java Program on basic java syntax
PDF
I have a Student.java class constructor like thisAnd I need to re.pdf
PDF
Hi, I need help with a java programming project. specifically practi.pdf
Need help with this java code. fill in lines where needed. Also, not.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
I need help with this code working Create another project and add yo.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
Array list
i am finishing a project for my cs 0401 java course. I have complete.pdf
Chapter 12 - File Input and Output
Java căn bản - Chapter12
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Oop lecture9 11
chapter 2(IO and stream)/chapter 2, IO and stream
Using Array Approach, Linked List approach, and Delete Byte Approach.pdf
File Handlingb in java. A brief presentation on file handling
Java Practical1 based on Basic assignment
Java programs
[10] Write a Java application which first reads data from the phoneb.pdf
Note- Can someone help me with the public boolean isEmpty()- public bo.pdf
Simple 27 Java Program on basic java syntax
I have a Student.java class constructor like thisAnd I need to re.pdf
Hi, I need help with a java programming project. specifically practi.pdf

More from angelnxcom (20)

PDF
1. Smart Labels are computerized, bar-coded label that is used to pr.pdf
PDF
1 ) a) Android Security One of the biggest challange is android sm.pdf
PDF
1) front to back2) smart dimension or noteSolution1) front t.pdf
PDF
Noonan syndrome is a developmental disorder. Noonan syndrome is a ge.pdf
PDF
Blastomyces dermatitidis, coccidiodies immitis and histoplasma capsu.pdf
PDF
When the compound is labeled as a liquid or aqueo.pdf
PDF
They represent exception as they have more than 8.pdf
PDF
The elements of inner transition elements differ .pdf
PDF
PV = n RT 15 x 0.068 x 1.01 = 0.75M x 0.0821 x .pdf
PDF
HOkay. So. Youve got Ruthenium(II)..this is y.pdf
PDF
H2Te H2SE H2S H2O .pdf
PDF
enthalpy of the given reaction is 4721 KJ since 4.pdf
PDF
z=2.55Solutionz=2.55.pdf
PDF
d) is incorrect .pdf
PDF
The matrix, the dominant component in the landscape, is the most ext.pdf
PDF
The non-disjunctioning had occur in her mother.Turners syndrome .pdf
PDF
The answer isB. HNO2, NO2+Conjugate acids have an extra H+ comp.pdf
PDF
Team 1 should start with Rohnda because of her no loss in fight 1 an.pdf
PDF
Rods are responsible for dim light vision and cones are responsible .pdf
PDF
Output SolutionOutput .pdf
1. Smart Labels are computerized, bar-coded label that is used to pr.pdf
1 ) a) Android Security One of the biggest challange is android sm.pdf
1) front to back2) smart dimension or noteSolution1) front t.pdf
Noonan syndrome is a developmental disorder. Noonan syndrome is a ge.pdf
Blastomyces dermatitidis, coccidiodies immitis and histoplasma capsu.pdf
When the compound is labeled as a liquid or aqueo.pdf
They represent exception as they have more than 8.pdf
The elements of inner transition elements differ .pdf
PV = n RT 15 x 0.068 x 1.01 = 0.75M x 0.0821 x .pdf
HOkay. So. Youve got Ruthenium(II)..this is y.pdf
H2Te H2SE H2S H2O .pdf
enthalpy of the given reaction is 4721 KJ since 4.pdf
z=2.55Solutionz=2.55.pdf
d) is incorrect .pdf
The matrix, the dominant component in the landscape, is the most ext.pdf
The non-disjunctioning had occur in her mother.Turners syndrome .pdf
The answer isB. HNO2, NO2+Conjugate acids have an extra H+ comp.pdf
Team 1 should start with Rohnda because of her no loss in fight 1 an.pdf
Rods are responsible for dim light vision and cones are responsible .pdf
Output SolutionOutput .pdf

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
GDM (1) (1).pptx small presentation for students
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Cell Structure & Organelles in detailed.
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
01-Introduction-to-Information-Management.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
Basic Mud Logging Guide for educational purpose
PPH.pptx obstetrics and gynecology in nursing
GDM (1) (1).pptx small presentation for students
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
RMMM.pdf make it easy to upload and study
Pharmacology of Heart Failure /Pharmacotherapy of CHF
STATICS OF THE RIGID BODIES Hibbelers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Cell Structure & Organelles in detailed.
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
01-Introduction-to-Information-Management.pdf
VCE English Exam - Section C Student Revision Booklet
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
TR - Agricultural Crops Production NC III.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
O5-L3 Freight Transport Ops (International) V1.pdf

in.txt ( Suppose if we store the text file in DDrive then the path .pdf