• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help in Making this library?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am trying to make a Library that will read some Input Files from a File .
Like When We Enter Nuber from a System.in
1
2
45
667

77
34

and then store these values in int[] array

What I want is I Save all these values in a File and at Run time pass path of that file to command line arguments
and then int[] array will be initialize using that

I hope I have cleared my problem statement if not please ask

something like this
http://introcs.cs.princeton.edu/java/stdlib/In.java.html

I am looking for


Thanks
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? Please show some of your work..
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is what I have try so far



I also try to run this but its not working
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, and can you be more specific about "It is not working"

Is there an error? Do you have a message / stack trace?
Is it doing something you don't expect?
What input are you giving it?
What output is it giving you?

As always, please ShowSomeEffort on your part.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Stefan Evans

This is my Effort


Is there an error? Do you have a message / stack trace?
Is it doing something you don't expect?
What input are you giving it?
What output is it giving you?


I will answar this what I am expecting in output

Suppose from main method I am calling it like

CustomInput customInput=new CustomInput("LocalDrive:\\path to my txt file.txt");
int[] arr=customInput.readAllInts();


And Suppose my file has Number in them like this

1
23
45
2
3
7
234
43
67
34
89
78
9
56
.
...



After the call to readAllInts() all values that are in this file should be store in myarray arr

But this is not happening

I hope now its more clear
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so what really happens instead of what you were expecting?

Did you try analyzing the problem yourself?
What do you think yourself that the problem might be?
Do you understand exactly what the code does, especially the regular expressions?
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, do you know whether those regular expressions differ from the default settings used by Scanner as its delimiter, etc?
Are you sure you want UTF-8 rather than ISO-8859-1? Are you using a Linux box, or Windows®?
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Also, do you know whether those regular expressions differ from the default settings used by Scanner as its delimiter, etc?
Are you sure you want UTF-8 rather than ISO-8859-1? Are you using a Linux box, or Windows®?


Now I have taken some reference from reference link I have pasted it working fine know
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what changes did you make to get it to work?
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for late reply

@Campbell

I just followed the refernce link and that worked for me
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!