N
naveen
hi,
i have a problem with file reading in java...
currently i am using the following Environment:
WSAD 5.1.0. for Windows
Oracle 8.1.7. 8i for Windows JDK 1.3.1.08 DB2 Client
IBM DB2 Windows XP
i am getting the "file not found error" in my Console
while retiving the values from the file...
i am calling file reading method from Servlet doPost()
here is the code snippet i used in main:
here is the declaration of the file:
private String _CRIT_Maintain_FileName =
"./WEB_INF/classes/com/d_systemes/osinet/base/Critsit_Maintenance.txt";
in servlet doPost() i am calling the file reader
method..
if
!(UserValidity.isValidUser(UserCurrent,"CRIT",_CRIT_Maintain_FileName))
{....};
the file reading method is:
public static boolean isValidUser(String
currentUser,String flag,String fileName) {
BufferedReader in= null;
try {
//Make sure that the Textfile exists and has valid
data records in a SingleLine.
//Otherwise, exceptions will occur.
in = new BufferedReader(new FileReader(fileName));
String str = null;
String validUser;
int start;
int end;
while ((str = in.readLine()) != null) {
//Using ',' as a Delimeter
if(str.charAt(0)==',')
start=1;
else
start=0;
end=str.indexOf(",");
while
((validUser=str.substring(start,end))!=null)
{
//Checking the cuurentUser value with the text
file value.
if(currentUser.equalsIgnoreCase(validUser.trim()))
{
return(true);
}
start=end+1;
end=str.indexOf(",",end+1);
}
}
in.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
but at the time of file reading i am getting the file
reading exception..can u plz tell me why i am getting
this error?...i kept the source file and the text file
in the current directory only..
i have a problem with file reading in java...
currently i am using the following Environment:
WSAD 5.1.0. for Windows
Oracle 8.1.7. 8i for Windows JDK 1.3.1.08 DB2 Client
IBM DB2 Windows XP
i am getting the "file not found error" in my Console
while retiving the values from the file...
i am calling file reading method from Servlet doPost()
here is the code snippet i used in main:
here is the declaration of the file:
private String _CRIT_Maintain_FileName =
"./WEB_INF/classes/com/d_systemes/osinet/base/Critsit_Maintenance.txt";
in servlet doPost() i am calling the file reader
method..
if
!(UserValidity.isValidUser(UserCurrent,"CRIT",_CRIT_Maintain_FileName))
{....};
the file reading method is:
public static boolean isValidUser(String
currentUser,String flag,String fileName) {
BufferedReader in= null;
try {
//Make sure that the Textfile exists and has valid
data records in a SingleLine.
//Otherwise, exceptions will occur.
in = new BufferedReader(new FileReader(fileName));
String str = null;
String validUser;
int start;
int end;
while ((str = in.readLine()) != null) {
//Using ',' as a Delimeter
if(str.charAt(0)==',')
start=1;
else
start=0;
end=str.indexOf(",");
while
((validUser=str.substring(start,end))!=null)
{
//Checking the cuurentUser value with the text
file value.
if(currentUser.equalsIgnoreCase(validUser.trim()))
{
return(true);
}
start=end+1;
end=str.indexOf(",",end+1);
}
}
in.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
but at the time of file reading i am getting the file
reading exception..can u plz tell me why i am getting
this error?...i kept the source file and the text file
in the current directory only..