Merge pull request #610 from purpleposeidon/patch-1

Add an InputStream constructor to WavefrontObject
This commit is contained in:
LexManos 2013-08-04 16:56:26 -07:00
commit b0f5f88482

View file

@ -49,20 +49,32 @@ public class WavefrontObject implements IModelCustom
public WavefrontObject(String fileName, URL resource) throws ModelFormatException public WavefrontObject(String fileName, URL resource) throws ModelFormatException
{ {
this.fileName = fileName; this.fileName = fileName;
loadObjModel(resource);
try
{
loadObjModel(resource.openStream());
}
catch (IOException e)
{
throw new ModelFormatException("IO Exception reading model format", e);
}
}
public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException
{
this.fileName = filename;
loadObjModel(inputStream);
} }
private void loadObjModel(URL fileURL) throws ModelFormatException private void loadObjModel(InputStream inputStream) throws ModelFormatException
{ {
BufferedReader reader = null; BufferedReader reader = null;
InputStream inputStream = null;
String currentLine = null; String currentLine = null;
int lineCount = 0; int lineCount = 0;
try try
{ {
inputStream = fileURL.openStream();
reader = new BufferedReader(new InputStreamReader(inputStream)); reader = new BufferedReader(new InputStreamReader(inputStream));
while ((currentLine = reader.readLine()) != null) while ((currentLine = reader.readLine()) != null)