I've inherited a bit of J2ME code where a single class has the following two methods in it:
public DataOutputStream getOutputStream(String filePath) throws IOException
{
return Connector.openDataOutputStream(filePath);
}
public DataOutputStream createOutputStream(String filePath) throws IOException
{
FileConnection fc = (FileConnection)Connector.open(filePath);
if(fc.exists())
return fc.openDataOutputStream();
else
fc.create();
return fc.openDataOutputStream();
}
As far as I can tell, these two methods do exactly the same thing. Bizarrely, the methods are right next to each other in the class, implying that whoever put them there knew what they were doing.
Are these methods essentially the same? Can I get rid of one of them? (Or probably both, thinking about it).