Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

text file accessing in Applet

Thread view: 
vidhi - 30 Jan 2006 11:48 GMT
i have an applet application which runns by useing values avilable in a
text file, as per the situation it rung great.
but the problem occures when multiple instance of applet over a network
is running and try to access the text file at same instance, in this
situation only one applet can have access the file and rest are hang up
at line which uses the file, one the applet file which have file access
grant will close then next but only one at this time also get the
access to that file.
i thought i might be sharing vocation problem.
here is the code what i use to access.

BufferedReader br=new BufferedReader(new
InputStreamReader(getClass().getResourceAsStream("MyTextFile.txt")));
try
{
    while((str=br.readLine())!= null)
    {
        strRange=br.readLine();
    }
}catch(IOException io){}
Matt Humphrey - 30 Jan 2006 20:49 GMT
>i have an applet application which runns by useing values avilable in a
> text file, as per the situation it rung great.
[quoted text clipped - 16 lines]
> }
> }catch(IOException io){}

It is up to the operating system (not java) to determine what happens when
the same file is opened multiple times, although usually multiple readers is
ok. Your code shows only file reading but it has some twists that make me
want to ask some questions.

1) When you say it runs great, does that mean the applet can read the file
when the applet and file (server) are on different machines?
2) When you say "and rest are hang up at line" do you mean they throw an
exception and if so what is the exception they throw?
3) Don't make empty exception  handlers--print any exception. Is there one
and what does it say?
4 Are you closing the file properly?
5) Is the file really being accessed via the classloader resource stream and
is in the jar file / classpath or is it supposed to be on the local machine?
6) Do you (or does any other code) attempt to write to the file?

Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.