• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

to find the count of text files in a directory..please help..

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to find a java code to count the number of text files in a folder and display the names of each of the files in form of radio buttons on screen for user to choose the file he wants to work with

kindly someone if possible help me providing the code for the count..
i also have problem as how to insert this code in applet???
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neha,
Welcome to the Ranch.

We do not just hand out ready made solutions here.
Why don't you post what have you got so far and we can help you figure out the rest?

Not applet related. Moving to an appropriate forum.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neha gautam wrote:
i also have problem as how to insert this code in applet???


As far as my knowledge is concerned, you can't do this, because Applets are run by the browser's JRE (Applet Viewer), so they can't access data from local machines (Its dangerous )
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

neha gautam wrote:
i also have problem as how to insert this code in applet???


As far as my knowledge is concerned, you can't do this, because Applets are run by the browser's JRE (Applet Viewer), so they can't access data from local machines (Its dangerous )


That is why we need to "sign" the applets
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to sign jars
http://java.sun.com/docs/books/tutorial/deployment/jar/signindex.html
 
neha gautam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:How to sign jars
http://java.sun.com/docs/books/tutorial/deployment/jar/signindex.html





i have the code for files in a directory where names of files is stored in an array(in java)...
now how do i redirect that array to my applet so that i can create an array of radio buttons equal to
the size of array, of my inital java code(file names array)....... finally my applet shud display each name of file as radio button..
i also have my code for radio buttons but i m findin trouble to combine both of them..
please help...
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neha gautam wrote:i have the code for files in a directory where names of files is stored in an array(in java)...
now how do i redirect that array to my applet so that i can create an array of radio buttons equal to
the size of array, of my inital java code(file names array)....... finally my applet shud display each name of file as radio button..
i also have my code for radio buttons but i m findin trouble to combine both of them..



I think, you didn't gave a thought to my post, This is simply impossible to do, you cant redirect(its word from your post) the the array of file names to the HTML page to display radio buttons.

Whats your requirement? what exactly your project ?, Its homework/practice code for Applets ?
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In pseudo code:
1) In the applet init() ensure the file array is prepared
2) Obtain the file array.
3) Prepare a panel with the appropriate layout.
4) Iterate through the file array
5) For every file, create a JRadioButton and add it to the panel
6) Add the panel to the applet

@Sagar
"how how do i redirect that array to my applet.."
 
neha gautam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

neha gautam wrote:i have the code for files in a directory where names of files is stored in an array(in java)...
now how do i redirect that array to my applet so that i can create an array of radio buttons equal to
the size of array, of my inital java code(file names array)....... finally my applet shud display each name of file as radio button..
i also have my code for radio buttons but i m findin trouble to combine both of them..



I think, you didn't gave a thought to my post, This is simply impossible to do, you cant redirect(its word from your post) the the array of file names to the HTML page to display radio buttons.

Whats your requirement? what exactly your project ?, Its homework/practice code for Applets ?



my requirement now is to develop a user interface that does the following:
1. its displays the number of files in a directory as radio buttons(text files).
2. allows user to choose from those
3. on the selected file's data i need to do check the numbr of colmns it has, i finally need to plot a graph from the file data
4.text file data is like

0.300, -124.87,
0.362, -127.36,
0.425, -129.30,
0.487, -131.52,
0.549, -133.48,
0.612, -135.43,
0.674, -137.19,
0.736, -138.74,
0.798, -140.21,
0.861, -141.52,
0.923, -142.71,
0.985, -143.86,
1.048, -144.94,
1.110, -146.01,
1.172, -146.87,
1.235, -147.60,
1.297, -148.74,
1.359, -149.45,
1.422, -150.16,
1.484, -151.03,
1.546, -151.56,
1.609, -152.31,
1.671, -152.99,
1.733, -153.76,
1.796, -154.51,
1.858, -155.06,
1.920, -155.84,
1.982, -156.17,
2.045, -156.96,
2.107, -157.54,
2.169, -158.13,
2.232, -158.84,
2.294, -159.37



and i need to finally see if there are only 2 columns then i need to insert another column with all zeros in it.
plot graph wid value of these colmns considering them as frequency and real part of input voltage..

kindly tell me if i have chosen a wrong platform to work on..
or please suggest me , the rite language to work on.. thankin you for all your help
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:@Sagar
"how how do i redirect that array to my applet.."


This same question I want to ask you, when I read your "pseudo code".

You simply can't have any file system rights when it comes to Applet, Correct me OR I'm missing something very silly ?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Neha
Where this files saved,
Answer,

1. On local machine -> Use Java Swing application
2. On server -> Get JSP/Servlet application
 
neha gautam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:@Neha
Where this files saved,
Answer,

1. On local machine -> Use Java Swing application
2. On server -> Get JSP/Servlet application



thanks sagar

on local machine...then i need to go for swing application..
i dont know much about swings..
can we do this fully in swings..
can GUI be made in swings..

thanks again
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:
...You simply can't have any file system rights when it comes to Applet, Correct me OR I'm missing something very silly ?



Check out the link I posted for signing jars.
Applets by default are not allowed to access the system resources. However if you sign the jars, the user is prompted for permissions. If the user grants the permission, the applet can access the system resources.
Also take a look at http://faq.javaranch.com/java/HowCanAnAppletReadFilesOnTheLocalFileSystem
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neha gautam wrote:

Sagar Rohankar wrote:@Neha
Where this files saved,
Answer,

1. On local machine -> Use Java Swing application
2. On server -> Get JSP/Servlet application



thanks sagar

on local machine...then i need to go for swing application..
i dont know much about swings..
can we do this fully in swings..
can GUI be made in swings..




Recommended reading
http://java.sun.com/docs/books/tutorial/uiswing/
http://faq.javaranch.com/java/SwingIsAProperNoun
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maneesh, I didn't know much about Applets and about signing them . Now I got it.

@Neha
You need some Java Swing tutorial
http://java.sun.com/docs/books/tutorial/uiswing/

Swing isn't difficult, but you should know who contain who and about layouts things.
Best Luck
 
neha gautam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:Thanks Maneesh, I didn't know much about Applets and about signing them . Now I got it.

@Neha
You need some Java Swing tutorial
http://java.sun.com/docs/books/tutorial/uiswing/

Swing isn't difficult, but you should know who contain who and about layouts things.
Best Luck



thanks to both of you guys
i just gave a look at it, i think i shud be able to manage..
if not... ill get bac to you people...
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neha gautam wrote:
if not... ill get bac to you people...


Yep, But be sure about posting it in right forum section

And Don't quote us every time, there is REPLY button below to last post.
 
neha gautam
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks...
i m a bit new to forums...
 
Do you pee on your compost? Does this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic