Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 56
Registered: ‎08-18-2011
My Device: Simulator
My Carrier: Developper

FielOutputStream deprecated

Hello pretty and wonderfull of beauty world !

 

I wrote this code but as you can't see FileOutputStream and the integer FILESYSTEM_PATRIOT are marked deprecated

 

public class Logger {

	public static Logger instance;
	public static DataOutputStream fluxDonnees;
	public FileOutputStream fluxFichier;

	public static Logger getInstance() {
		if (instance == null) {
			instance = new Logger();
		}
		return instance;
	}

	public Logger() {
		try {
			this.fluxFichier = new FileOutputStream(File.FILESYSTEM_PATRIOT,
					"JournalBlackRep.log");
		} catch (IOException e) {

		}
		fluxDonnees = new DataOutputStream(this.fluxFichier);

	}

	public static void ecriture(String aMessage) {
		try {
			fluxDonnees.writeUTF(aMessage);
		} catch (IOException e) {

		}
	}
}

 

So what class to use instead ?

 

And otherway where could i find my log file ?

 

Thanks and Regards anybody for an answer

Retired
Retired
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified
My Carrier: Rogers

Re: FielOutputStream deprecated

Hi!

 

The deprecation message is a bit misleading, it says to use "javax.microedition.io.file" but that's just the package name.  I suspect javax.microedition.io.file.FileConnection is probably the class you want...

Regular Contributor
Posts: 56
Registered: ‎08-18-2011
My Device: Simulator
My Carrier: Developper

Re: FielOutputStream deprecated

Thanks for your answer. I di wrote this code but did not debug it for the moment :

 

public Logger() {
		try {
			Connector.open("File:///SDCard/");
			Logger.fluxDonnees = Connector
					.openDataOutputStream("LogBlackRep.log");
		} catch (IOException IOe) {
			System.out.println(IOe.getMessage());
			Logger.ecriture(IOe.getMessage());
		}
	}

 Does it seem right for you ?

Retired
Retired
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified
My Carrier: Rogers

Re: FielOutputStream deprecated

If it works, then yes Smiley Very Happy

Regular Contributor
Posts: 56
Registered: ‎08-18-2011
My Device: Simulator
My Carrier: Developper

Re: FielOutputStream deprecated

@BVP

And your mind, can it work or not ?

Is it a joke, another from a private network of a proprietary system for professionnals agreed only ?

 

Highlighted
Regular Contributor
Posts: 56
Registered: ‎08-18-2011
My Device: Simulator
My Carrier: Developper

Re: FielOutputStream deprecated

OKEY.....

 

It seems to work better (found on StackOverFlow for whose like Inormations) :

 

public class Logger {

	private static Logger instance;
	private static DataOutputStream fluxDonnees;
	private static FileConnection connexionFichier ;

	public static Logger getInstance() {
		if (instance == null) {
			instance = new Logger();
		}
		return instance;
	}

	private Logger() {
		try {
			connexionFichier = (FileConnection) Connector.open("File:///SDCard/LogBlackRep.log", Connector.READ_WRITE);
			if (!connexionFichier.exists()) {
				connexionFichier.create();
			}
			fluxDonnees = connexionFichier.openDataOutputStream();
		} catch (IOException IOe) {
			System.out.println(IOe.getMessage());
			Logger.ecriture(IOe.getMessage());
		}
	}

	public static void ecriture(String aMessage) {
		try {
			fluxDonnees.writeUTF(aMessage);
		} catch (IOException IOe) {
			System.out.println(IOe.getMessage());
			Logger.ecriture(IOe.getMessage());
		}
	}
}

 And No Thanks @ whose doesn't know himself