A complete 3D game development suite written purely in Java.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jmonkeyengine/sdk/jme3-blender/src/com/jme3/gde/blender/OutputReader.java

61 lines
1.4 KiB

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.blender;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.api.progress.ProgressHandle;
/**
*
* @author normenhansen
*/
public class OutputReader implements Runnable {
private Thread thread;
private BufferedReader in;
private ProgressHandle progress;
public OutputReader(InputStream in) {
this.in = new BufferedReader(new InputStreamReader(in));
}
public OutputReader(BufferedReader in) {
this.in = in;
}
public void start() {
thread = new Thread(this);
thread.start();
}
public void run() {
try {
String line;
while ((line = in.readLine()) != null) {
if (line.trim().length() > 0) {
if (progress != null) {
progress.progress(line);
} else {
Logger.getLogger(OutputReader.class.getName()).log(Level.INFO, "{0}",line);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @param progress the progress to set
*/
public void setProgress(ProgressHandle progress) {
this.progress = progress;
}
}