You Are Here:

Community: Developer Discussion Boards

#1 Old JSR75 - Delete File, no "real" Exception - 2007-06-21, 12:09

Join Date: Jun 2007
Posts: 10
MGvision
Offline
Registered User
hi @all,

i'm trying to delete a File by usiing this code:

Code:
		try
				{ 
					String dir2 = "file:///" + settingsCtrl.getLocal_dir() + filename;
					FileConnection filecon = (FileConnection)Connector.open(dir2);
					if(filecon.exists()) {
						System.out.println(dir2);
						filecon.delete();
					}
					filecon.close();	
					display.setCurrent(parent);
			        
				}catch (Exception e) {
					System.out.println(e.toString());
				}
but the output is:
Code:
file:///root/Documents/xml/test.xml
java.io.IOException: 
Execution completed.
so the sys.out is handled correctly, but the delete() method is buggy.
Even though, the file exists!
as you can see, the System.out.println(e.toString()); does not give me a hint, whats going wrong.

can you maybe help me?

thank you very much in advance,
martin
Reply With Quote

#2 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-21, 13:05

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Where are you getting the exception.While you do file connection or when u delete a file.
Thanks
Soku
Reply With Quote

#3 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-21, 14:35

Join Date: Jun 2007
Posts: 10
MGvision
Offline
Registered User
hi soku123,

i did some changes do debug:
Code:
try
{ 
	String dir2 = "file:///" + settingsCtrl.getLocal_dir() + filename;
	FileConnection filecon = (FileConnection)Connector.open(dir2);
	
	try
	{
		if(filecon.exists()) {
			System.out.println(dir2);
			filecon.delete();
		}
		filecon.close();	
		display.setCurrent(parent);
	}catch (Exception e) {
		System.out.println("delete:" + e.toString());
	}				
    
}catch (Exception e) {
	System.out.println("connection:" + e.toString());
	}					
}
I'm getting a:
Quote:
delete:java.io.IOException:
Execution completed.
so its something with the delete ;)

thanks,
Martin
Reply With Quote

#4 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-22, 11:25

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Did it print System.out.println(dir2);????

Thanks
Soku
Reply With Quote

#5 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-22, 11:45

Join Date: Jun 2007
Posts: 10
MGvision
Offline
Registered User
jeah i do get the dir2 output ;)
Reply With Quote

#6 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-22, 15:00

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Debug the code using system.out.println() befor filecon.close(), display.setCurrent(parent); and ensure that the exception occurs at delete().
Thanks
Soku
Reply With Quote

#7 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-22, 15:12

Join Date: Jun 2007
Posts: 10
MGvision
Offline
Registered User
Code:
try
				{ 
					String dir2 = "file:///" + settingsCtrl.getLocal_dir() + getFilename();
					System.out.println(dir2);
					FileConnection filecon = (FileConnection)Connector.open(dir2);
					if(filecon.exists()) {						
						filecon.delete();
					}
					
					try
					{
						filecon.close();	
						display.setCurrent(parent);
					}catch (Exception e) {
						System.out.println("delete:" + e.toString());
					}
					
			        
				}catch (Exception e) 
				{
					System.out.println("connection:" + e.toString());
				}
file:///root/Documents/xml/test.xml
connection:java.io.IOException:

so it's the
if(filecon.exists()) {
filecon.delete();
}

part ..
hmmm
Reply With Quote

#8 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-23, 18:55

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Have u given the fileconnection READ_WRITE permission.
Thanks
Soku
Reply With Quote

#9 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-24, 20:30

Join Date: Jun 2007
Posts: 10
MGvision
Offline
Registered User
hi, here is my newest code:

Code:
try
				{ 
					String dir2 = "file:///" + settingsCtrl.getLocal_dir() + getFilename();
					System.out.println(dir2);
					FileConnection filecon = (FileConnection)Connector.open(dir2, Connector.READ_WRITE);

					try
					{
						if(filecon.exists()) {						
							filecon.delete();
						}
						
						filecon.close();	
						display.setCurrent(parent);
					}catch (Exception e) {
						System.out.println("delete:" + e.toString());
					}
					
			        
				}catch (Exception e) 
				{
					System.out.println("connection:" + e.toString());
				}
delete:java.io.IOException:
Reply With Quote

#10 Old Re: JSR75 - Delete File, no "real" Exception - 2007-06-26, 07:51

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Debug the code using system.out.println() befor filecon.close(), display.setCurrent(parent);and please post the output..
Thanks
Soku
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Tips on using NDS 1.1 mitts Symbian Tools & SDKs 7 2006-01-18 17:07
Strange behavior on sending jar file via WAP for different mobile network thone Mobile Java General 0 2005-10-27 21:51
What is the error in my code here? Unable to Save document to file yuva69 General Symbian C++ 1 2005-05-26 15:22
How to reformat the file? ryanfunghk Symbian Networking & Messaging 0 2005-03-26 18:43
nokia 7210 modem via IR doesn't work ! oussamaaiadi PC Suite API and PC Connectivity SDK 1 2003-03-06 11:46

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia