Assuming that I use the following code to connect to a SOCKS5 proxy, would connections or packets sent by an applet that I instantiate go through the same proxy?
System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", "*.*.*.*");
System.getProperties().setProperty("socksProxyPort", "*");
Applet is started using a classloader object from which a newInstance is created.
classLoader = new CustomClassLoader(/* Hashmap of byte arrays */); // Custom classloader that works using byte arrays
Applet applet = (Applet) classLoader.loadClass("class").newInstance();
applet.setStub(stub);
applet.init();
applet.start();
frame.add(applet);
It appears that the answer to this question is yes.
The following code:
public class TestApplet extends Applet {
private String ip;
public void init() {
try {
URL ipCheck = new URL("http://checkip.amazonaws.com");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ipCheck.openStream()));
ip = bufferedReader.readLine();
bufferedReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public void stop() {
}
public void paint(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.CYAN);
g.drawString("Current IP: " + ip, 10, 20);
}
}
and
public class Boot {
public static void main(String[] args) {
System.getProperties().setProperty("socksProxySet", "true");
System.getProperties().setProperty("socksProxyHost", "71.9.127.141"); //Credits to HideMyAss.com
System.getProperties().setProperty("socksProxyPort", "28045");//Credits to HideMyAss.com
new Thread(new Runnable() {
#Override
public void run() {
try {
Thread.sleep(5000);
} catch (Exception e) {
e.printStackTrace();
}
TestApplet testApplet = new TestApplet();
testApplet.init();
JFrame jFrame = new JFrame();
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.setSize(500, 500);
jFrame.setContentPane(testApplet);
jFrame.setVisible(true);
}
}).start();
}
}
Outputs:
Tyler, if I understand your question correctly - yes. But this comes with a caveat: the System properties that you set will persist only across the current JVM instantiation.
So, if like your example shows you set the properties and execute the Applet on the same JVM you should be fine.
Related
Very simply, I could not draw this image.
public class RenderMap extends JPanel {
static BufferedImage brick;
static BufferedImage groundb;
public static void main(String[] args) {
JFrame window = new JFrame("Super Mario");
RenderMap content = new RenderMap();
window.setContentPane(content);
window.setBackground(Color.WHITE);
window.setSize(1200, 800);
window.setLocation(100,0);
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
window.setResizable(false);
window.setVisible(true);
try {
brick = ImageIO.read(new File("SuperMario/brick.png"));
} catch (IOException e) {
}
try {
URL url = new URL("SuperMario/brick.png");
brick = ImageIO.read(url);
} catch (IOException e) {
}
try {
groundb = ImageIO.read(new File("SuperMario/ground.png"));
} catch (IOException e) {
}
try {
URL url = new URL("SuperMario/ground.png");
groundb = ImageIO.read(url);
} catch (IOException e) {
}
}
public Ground ground;
public RenderMap() {}
public void paintComponent(Graphics g) {
if(ground == null) {
ground = new Ground();
}
ground.draw(g);
}
public class Ground implements ImageObserver {
Ground(){}
void draw(Graphics g) {
g.drawImage(groundb, 0, 0, 1200, 800, this);
g.fillOval( 8, 8, 16, 16);
}
#Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
// TODO Auto-generated method stub
return false;
}
}
}
This draws the oval, but not the image. I tried changing to another image(that is functioning in another program) and it still won't work, so I know it's not the image's problem.
As suspected, the images are not being loaded properly.
java.net.MalformedURLException: no protocol: SuperMario/brick.png
at java.net.URL.<init>(URL.java:586)
at java.net.URL.<init>(URL.java:483)
at java.net.URL.<init>(URL.java:432)
at RenderMap.main(RenderMap.java:40)
java.net.MalformedURLException: no protocol: SuperMario/ground.png
at java.net.URL.<init>(URL.java:586)
at java.net.URL.<init>(URL.java:483)
at java.net.URL.<init>(URL.java:432)
at RenderMap.main(RenderMap.java:51)
It's failing at the load-by-URL function calls because you passed in an invalid URL. Correct URL format should be like how you access them from a web browser, like: http://someplace.com/SuperMarioFolder/brick.png
To load the images, choose only one way to read them. Either by:
URL - Remove the File blocks and make the file accessible via full URL.
try {
URL url = new URL("http://www.proper-url.com/SuperMario/ground.png");
groundb = ImageIO.read(url);
} catch (IOException e) { }
File - Remove the URL blocks. This will only allow the program to access local files.
try {
groundb = ImageIO.read(new File("SuperMario/ground.png"));
} catch (IOException e) {
}
For your project's purpose, I believe option#2 would suffice.
Moving forward, you may want to use an IDE's debugging feature to go through code execution step-by-step. If you're not using one, you may want to IntelliJ and Eclipse.
I am currently working on a small application to display/save notes. The content of each note is stored inside a .properties file on my hard drive after closing the application. If you open the application again then all notes are loading inside the application.
While this loading process is taking place, I show a dialog box with a progressbar that indicates the state of the process. Furthermore, I display a GlassPane so the user can’t interact with the GUI or crate/save notes while loading.
Following is my current Code for loading the notes:
public void load() {
new Thread() {
#Override
public void run() {
Properties data = new Properties();
FileInputStream iStream = null;
File[] files = sortPairs();
int fileIndex = -1;
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
pnlGlass = new MyGlassPane();
infoText = new JTextField();
progBar = new JProgressBar(0,100);
progBar.setValue(0);
progBar.setStringPainted(true);
infoBox = new LoadInfoDialog(infoText,progBar);
infoBox.setLocationRelativeTo(gui);
infoBox.setVisible(true);
infoBox.setDefaultCloseOperation(infoBox.DO_NOTHING_ON_CLOSE);
pnlGlass.setOpaque(false);
pnlGlass.addMouseListener(new MouseAdapter() {
#Override
public void mousePressed(MouseEvent me) {
me.consume();
}
});
gui.setGlassPane(pnlGlass);
pnlGlass.setVisible(true);
pnlGlass.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
});
for (File file : files) {
if (file.isFile()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
iStream = new FileInputStream(file);
data.load(iStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (!(iStream == null)) {
try {
iStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String title = data.getProperty("title");
String text = data.getProperty("text");
String erstellt = data.getProperty("date");
String fileName = data.getProperty("filename");
Note note = new Note(text, title);
note.setFileName(fileName);
note.setDate(erstellt);
fileIndex++;
final int fileIndexFinal = fileIndex;
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
progBar.setValue(progBar.getValue() + 100 / fileCount);
infoText.setText("Lade Notizen, bitte warten..." + progBar.getValue() + "%");
noteModel.addNote(note);
System.out.println("Index:" + fileIndexFinal);
}
});
}
}
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
pnlGlass.setVisible(false);
infoBox.setVisible(false);
}
});
}
}.start();
}
I am sure that my solution is pretty ragged. After some research I figured that there is a class called "SwingWorker" for exactly this purpose (running Taks in background and update gui) BUT, how can I create my note (add Note-Object to my Model) from within the SwingWorker?
I know that I can update my progressbar using the publish and process methods but how can I create an object using the SwingWorker?
The loading process should do the following routine for every note:
Read content from .properties file -> create note Object -> show note in JList -> update progressbar.
Start by defining your core worker...
public class NotesLoader extends SwingWorker<List<Properties>, Properties> {
#Override
protected List<Properties> doInBackground() throws Exception {
List<Properties> notes = new ArrayList<>(25);
File[] files = new File(".").listFiles(new FilenameFilter() {
#Override
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".properties");
}
});
for (File file : files) {
int count = 0;
try (Reader reader = new FileReader(file)) {
Properties note = new Properties();
note.load(reader);
notes.add(note);
publish(note);
setProgress((int) ((count / (double) files.length) * 100d));
}
}
return notes;
}
}
This simple scans the current working directory for .properties files and tries to load them one at a time. When one is loaded, it is sent via the publish method and the progress is updated via the setProgress method.
Now, I devised a simple progress panel which looks like this...
public class LoadingPane extends JPanel {
private JLabel label;
private JProgressBar pb;
public LoadingPane() {
setLayout(new GridBagLayout());
setOpaque(false);
label = new JLabel("Loading, please wait");
pb = new JProgressBar();
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
add(label, gbc);
add(pb, gbc);
addMouseListener(new MouseAdapter() {
});
setFocusable(true);
}
public void setProgress(float progress) {
pb.setValue((int) (progress * 100f));
}
#Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g.create();
g2d.setColor(new Color(128, 128, 128, 128));
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.dispose();
}
}
This is important, as it has a setProgress method
Now, we can use these two together to load the notes in the background and update the UI safely as the progress updates.
LoadingPane loadingPane = new LoadingPane();
JFrame frame = new JFrame("Testing");
frame.setGlassPane(loadingPane);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JLabel("I'll wait here okay"));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
NotesLoader loader = new NotesLoader() {
#Override
protected void process(List<Properties> chunks) {
System.out.println(chunks.size() + " notes were loaded");
// Update you model??
}
};
loader.addPropertyChangeListener(new PropertyChangeListener() {
#Override
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
switch (name) {
case "state":
switch (loader.getState()) {
case STARTED:
frame.getGlassPane().setVisible(true);
frame.getGlassPane().requestFocusInWindow();
break;
case DONE:
frame.getGlassPane().setVisible(false);
try {
// Doubt your need the list, but it's good to do this
// incase there was an exception which occured during
// the running of the worker
List<Properties> notes = loader.get();
} catch (InterruptedException | ExecutionException ex) {
ex.printStackTrace();
// Maybe show an error message...
}
break;
}
break;
case "progress":
// I like working with normalised values :P
loadingPane.setProgress(((int)evt.getNewValue() / 100f));
break;
}
}
});
The example overrides the process method, so you can get the notes as they are loaded, but equally, you could wait till the state changes to DONE and get them all at once, it's up to you
I am trying to do live stream from RPi camera in java but I have problem because I am very new in this kind of programming and didn't find answer that would help me with this.
I have my server app from this page: enter link description here
It works with .NET but I want to do whole thing in Java(UDP version in my case).
I was following documentation on enter link description here but it still doesn't work.
Here is my code of the client app:
public class CamService {
public static IDuplexOutputChannel myVideoChannel;
public static String StreamAddr = "udp://192.168.0.145:8093/";
public static OutputStream myVideoStream;
public static BufferedOutputStream bOut;
public static String pName;
public static void main(String[] args) throws Exception {
JFrame frame;
EmbeddedMediaPlayerComponent mediaPlayerComponent;
new NativeDiscovery().discover();
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "c:\\program files (x86)\\videolan\\vlc\\");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
IMessagingSystemFactory aMessaging = new UdpMessagingSystemFactory();
myVideoChannel = aMessaging.createDuplexOutputChannel(StreamAddr);
myVideoChannel.responseMessageReceived().subscribe(myOnResponseMessageReceived);
frame = new JFrame("AWWWW!");
frame.setBounds(100, 100, 600, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame.addWindowListener(new WindowAdapter() {
#Override
public void windowClosing(WindowEvent e) {
mediaPlayerComponent.release();
myVideoChannel.closeConnection();
System.exit(0);
}
});
frame.setContentPane(mediaPlayerComponent);
frame.setVisible(true);
String[] mediaOptions = {
":sout=#transcode{vcodec=h264,venc=x264{preset=ultrafast},vb=512 }"
+ ":std{access=udp,mux=ts}" };
Media media = new SimpleMedia(StreamAddr, mediaOptions);
mediaPlayerComponent.getMediaPlayer().playMedia(media);
myVideoChannel.openConnection();
}
private static void onResponseMessageReceived(Object sender, DuplexChannelMessageEventArgs e) throws IOException
{
byte[] aMessage = (byte[])e.getMessage();
System.out.println("Byte message: " + aMessage);
myVideoStream.write(aMessage, 0, aMessage.length);
bOut = new BufferedOutputStream(myVideoStream);
System.out.println("Buffered Output: " + myVideoStream);
}
private static EventHandler<DuplexChannelMessageEventArgs> myOnResponseMessageReceived = new EventHandler<DuplexChannelMessageEventArgs>()
{
#Override
public void onEvent(Object sender, DuplexChannelMessageEventArgs e)
{
try {
onResponseMessageReceived(sender, e);
} catch (IOException e1) {
System.out.println("NOPE");
e1.printStackTrace();
}
}
};
}
I am not getting any errors while compiling it. It connects to server, turning on the camera but it doesn't stream it. After closing program i am getting:
main stream error: cannot pre fill buffer
Would be very thankful for ANY help with this.
Thanks.
Trying to get an image from another application sending an array of bytes through socket, translating it to a BufferedImage and setting a JLabel in the GUI that updates every 3 seconds.
I tried looking it up on forums but questions regarding graphical update are recurrent to me and I never seem to get it right -- there's at least 6 update methods in java for graphical interface and every one I tried won't work.
I know the problem isn't in the connection to the client because I can easily save the image I receive with ImageIO.write() and it updates every 3 seconds to the image I was expecting to receive. I just can't have Java updating the JLabel correctly without having to go to forums and ask people. Such a complex task I guess. Here is the code: http://pastebin.com/95nMGLvZ. I am doing this project in Netbeans so there's a lot of stuff in there that is unnecessary to read as it does not directly relate to the problem.
I think the answer lies in creating a separate thread to update my JLabel from the ever-changing BufferedImage that is received from the ObjectInputStream. Anyone mind giving me a hand at this? What is better for my code? SwingWorker, Threading (wtf is setDaemon(flag)?), Runnable, Timer, invokeLater? Tried all of this. Not correctly apparently.
EDIT1:
Tried your answer immibis:
public void startRunning() {
try {
server = new ServerSocket(666, 10);
connection = server.accept();
networkStatus("Connected to " + connection.getInetAddress().getHostName());
Thread thr = new Thread(new Runnable() {
#Override
public void run() {
try {
input = new ObjectInputStream(connection.getInputStream());
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.toString());
}
}
});
thr.start();
System.out.println(!connection.isInputShutdown());
while (connection.isConnected()) {
try {
byte[] byteImage = (byte[]) input.readObject();
InputStream in = new ByteArrayInputStream(byteImage);
final BufferedImage bi = ImageIO.read(in);
jLabel_screen.setIcon(new ImageIcon(bi));
ImageIO.write(bi, "jpg", new File("C:\\Users\\User\\Desktop\\test.jpg"));
System.out.println("i'm working");
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.toString());
} catch (ClassNotFoundException ex) {
Logger.getLogger(SpyxServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.toString());
}
}
It does not work. It says byte[] byteImage = (byte[]) input.readObject(); line has a NullPointerException. The only value that can be null is the return from readObject(), meaning either the input was not initialized correctly or the connection is not synchronized. I hope it's the first option because I wouldn't know how to handle the last.
EDIT2:
Tried your answer blazetopher:
public void startRunning() throws IOException {
server = new ServerSocket(666, 10);
try {
connection = server.accept();
networkStatus("Connected to " + connection.getInetAddress().getHostName());
input = new ObjectInputStream(connection.getInputStream());
while (true) {
try {
byte[] byteImage = (byte[]) input.readObject();
InputStream in = new ByteArrayInputStream(byteImage);
final BufferedImage bi = ImageIO.read(in);
SwingUtilities.invokeLater(new Runnable() {//<-----------
#Override
public void run() {
jLabel_screen.setIcon(new ImageIcon(bi));
}
});
ImageIO.write(bi, "jpg", new File("C:\\Users\\User\\Desktop\\test.jpg"));
System.out.println("i'm working");
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.toString());
} catch (ClassNotFoundException ex) {
Logger.getLogger(SpyxServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
} catch (EOFException eofException) {
networkStatus("Connection Closed. :(");
} finally {
input.close();
connection.close();
}
}
Using SwingUtilities.invokeLater didn't work either. At least the program runs and can even save the image but still can't update the JLabel. Am I running out of options here?
EDIT3:
Tried Jordan's code:
#Override
public void paint(Graphics g) {
g.drawImage(biGlobal, 0, 0, null);
}
The GUI kind of crashed and was "drawing" the components just when I had my mouse cursor hovering it. When I started the code, it did not crashed (+1) but it did not draw anything, even when I try to hover the cursor into where the BufferedImage should be painted. Maybe I should add revalidate() or repaint after calling the Overwritten paint(getGraphics()) inside the startRunning() method?
EDIT4: the while(true) that the code is actually in may be the problem but when I use a SwingTimer it gets out of sync with the client and crashes after first cycle. Any alternatives to this?
Generally speaking you have a producer/consumer pattern. Something is producing images and something wants to consume images. Normally, the consumer would wait on the producer to tell it something has been produced, but in this case, we can use a observer pattern instead, having the producer notify the consumer that something was been produced (instead of waiting for it)
We need someway for the producer to communicate with the consumer...
public interface PictureConsumer {
public void newPicture(BufferedImage img);
}
You would create an implementation of this in your UI code, this would then set the icon property of the JLabel
Now, we need something to produce the images...
public class PictureProducer extends SwingWorker<Object, BufferedImage> {
private PictureConsumer consumer;
public PictureProducer(PictureConsumer consumer) {
this.consumer = consumer;
}
#Override
protected void process(List<BufferedImage> chunks) {
// Really only interested in the last image
BufferedImage img = chunks.get(chunks.size() - 1);
consumer.newPicture(img);
}
#Override
protected Object doInBackground() throws Exception {
/*
This whole setup worries me. Why is this program acting as the
server? Why aren't we pooling the image producer?
*/
try (ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(666, 10)) {
try (Socket socket = server.accept()) {
try (ObjectInputStream ois = new ObjectInputStream(socket.getInputStream())) {
// Using `while (true)` is a bad idea, relying on the fact
// that an exception would be thrown when the connection is closed is
// a bad idea.
while (!socket.isClosed()) {
// Generally, I'd discourage using an ObjectInputStream, this
// is just me, but you could just as easily read directly from
// the ByteArrayInputStream...assuming the sender was sending
// the data as a byte stream ;)
byte[] bytes = (byte[]) ois.readObject();
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes)) {
BufferedImage img = ImageIO.read(bis);
publish(img);
}
}
}
}
}
return null;
}
#Override
protected void done() {
try {
get();
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Image Producer has failed: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
See Worker Threads and SwingWorker for more details
You can a reverse example of this (where some server is producing images and a client is consuming them) here
To update your label, you want to ensure you're using the EDT thread, so use SwingUtilities.invokeLater from the code where you're receiving the BufferedImage (which would ideally be in a separate "worker" thread:
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
// Update your label here
}
});
What is it you are attempting to accomplish.there might be a better way all together.
For example replace the JLabel with a JPanel then use that JPanel paint method
#Override
public void paint(Graphics g) {
g.drawImage(Img, xcord, ycord, null);
}
Then make that JPanel implement runnable and do your updates in that run method.
JPanel class
public class GraphicsPanel extends JPanel{
private BufferedImage img;
#Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D G2D = (Graphics2D) g;
G2D.drawImage(img, 0, 0, null);
}
public void setImg(BufferedImage img) {
this.img = img;
}
}
then make sure this panel is visible from wherever you wish to call its methods.
this will look something like this
GraphicsPanel graphicsPanel = new GraphicsPanel();
boolean running;
BufferedImage srcImage;
public void run(){
while(running){
graphicsPanel.setImg(srcImage);
graphicsPanel.repaint();
try {
Thread.sleep(300);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
javac cannot find this class : StreamedTextArea() which I assumed was part of java.awt.*. If I need to write it myself then can anyone offer me some advice. The only references to it online were from ~1999 which inclines me to think it is not a Sun class but one I must write myself. Also in this code (which is from a textbook) they use Frame instead of JFrame. Is this deprecated, how should this application be written nowadays ? Please I have tried finding the answers myself online but to no avail.
The application :
//URLViewer.java
//This is a simple application that provides a window in which you can view the
//contents of a URL.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class URLViewer extends Frame implements WindowListener, ActionListener {
TextField theURL = new TextField();
Button loadbutton = new Button("load");
StreamedTextArea theDisplay = new StreamedTextArea();
public URLViewer() {
super ("URL Viewer");
}
public void init() {
this.add("North", theURL);
this.add("Center", theDisplay);
Panel south = new Panel();
south.add(loadbutton);
this.add("South", south);
theURL.addActionListener(this);
this.addWindowListener(this);
this.setLocation(50, 50);
this.pack();
this.show();
}
public void actionPerformed (ActionEvent evt) {
try {
URL u = new URL (theURL.getText());
InputStream in = u.openStream();
OutputStream out = theDisplay.getOutputStream();
StreamCopier.copy(in, out);
in.close();
out.close();
} catch (MalformedURLException ex) {theDisplay.setText("Invalid URL");}
catch (IOException ex) {theDisplay.setText("Invalid URL");}
}
public void windowClosing (WindowEvent e) {
this.setVisible(false);
this.dispose();
}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public static void main (String[] args) {
URLViewer me = new URLViewer();
me.init();
}
}
And StreamCopier :
import java.io.*;
public class StreamCopier {
public static void main (String[] args) {
try {
copy (null, null);
} catch (IOException e) {System.err.println(e);}
}
public static void copy (InputStream in, OutputStream out) throws IOException {
//do not allow other threads to read from the input or
//write to the output while copying is taking place.
synchronized (in) {
synchronized (out) {
byte [] buffer = new byte [256];
while (true) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) break;
out.write(buffer, 0, bytesRead);
}
}
}
} //end copy()
}
Here is StreamedTextArea.java. I found it on this page, which also has code that matches your StreamCopier class. This page also contains information on that site.