Shaun Brierly

Greenhorn
+ Follow
since Aug 22, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Shaun Brierly

Hmmm, whoops, for some reason I thought the print out was scrambled data =( due to once I had transfered a text file, and it was repeated, telling me every chunk was the same, it appears to work, hehe thanks =)
Shaun Brierly
22 years ago
The Print out is actually on the server... this is what it looks like...
[B@7b6889
[B@7b6889
[B@7b6889
[B@7b6889
[B@7b6889
[B@7b6889... etc
So this is what's coming out of the socket... I know my problem is with Java arrays, considering if I put array = new bytes[4196]; in the while loop the data is sent correctly, however the client's memory is brought to it's knees.
Shaun Brierly
22 years ago
Thanks for replies, I used the functions you described, and my orignal problem still remains... the same information is being passed over and over again, the only way I can get it to work is if I throw a byte = new byte[4096] in the loop and it destroys memory... I know it seems very weird... i'm using 1.4
22 years ago
Hi, thanks for replies, yes that's exactly what I have, however for some reason the buffer is never updated... I read a post in Google Groups that it's a problem where the array itself is an object and when you pass it as the array it keeps the same reference to it or something, so it doesn't get updated or something. When I do System.out.println(array);
System.out.println(array[0]);
the first always prints out the same thing
while the 2nd line always prints out a different value. Yes, I know, very weird, which is why i'm trying to figure out why it's doing this...
Thanks,
Shaun
22 years ago
Thanks for reply however, if I clone my array everytime it runs though a loop the computer it's being run on would be crippled... the Array is an array of bytes being read in chunks of 4196 bytes and sent through a socket, That would be alot of clones for large files!
Shaun Brierly
22 years ago
I'm not sure if Sun considers this a "feature" or what, but i'm having trouble with an array in a while loop, the Array gets changed each time though the loop, however the way Java references objects, the Array's reference never changes, and when I try to pass the Array to get processed, it sends the same reference, which contains the orignal data of the 1st iteration through the loop, however when I System.out.println( array[0] ); you can see the data is changing... any work arounds to this? This is a pretty rediculous bug, or whatever, sounds intentional...
Thanks,
Shaun Brierly
22 years ago
I forgot to take out array = new byte[CHUNK_SIZE] in the code, technically the code as is works, however is very bad for memory... however when I take out the line array never gets overwritten for some strange reason...
Shaun Brierly
22 years ago
I have a very odd problem... the code below sends the same bytes over and over... the function FileInputStream.read(bytes[]) will not overwrite what's already in array, unless I call array = new byte[CHUNK_SIZE] in the while loop which is very ugly for memory, and if the file is large enough will destroy the system... any ideas?

public void uploadFile(final String path, final String dest) {

tTransferThread = new Thread(new Runnable() {
public void run() {



String fInput;
String fDest;
try {
FileInputStream f = new FileInputStream (path);
int size = f.available();
byte[] array = new byte[CHUNK_SIZE];
byte[] cleanArray = new byte[CHUNK_SIZE];
fDest = dest + "/" + path.substring(path.lastIndexOf("\\") + 1);
fDest = fDest.replace('\\', '/');

write("upload ");
uploadStream.writeObject((Object)fDest);
uploadStream.flush();
int byteCounter = 0;
byte[] tempArray;
int counter;
int bytesRead = CHUNK_SIZE;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
uwUpload.mainPanel.show();
} // END run
});

uwUpload.setProgress(0);
uwUpload.setStatus("Uploading: " + path.substring(path.lastIndexOf("\\") + 1));
while(byteCounter < size) {

array = new byte[CHUNK_SIZE];

bytesRead = f.read(array);
System.out.println(array);
byteCounter+=bytesRead;

Thread.sleep(10);

uwUpload.setProgress( (int)((double)
if(bytesRead < CHUNK_SIZE) {
tempArray = new byte[bytesRead];
for(counter=0; counter<bytesRead; counter++)
tempArray[counter] = array[counter];

uploadStream.writeObject((Object)tempArray);
} else
uploadStream.writeObject((Object)array);

uploadStream.flush();

}
uploadStream.writeObject((Object)"~~~doneWHEEE~~~");

} // END try
catch(Exception e) { System.out.println("error"); e.printStackTrace(); }
}});
tTransferThread.start();
} // END uploadFile
22 years ago
Greets,
I'm using Java 1.4 SSLSockets. I have a keystore and on the command line I set the system properties truststore and truststorepassword. This was working fine till this morning, I got a certificate error, and it appears my Keystore had expired. Anyone know how to make a Keystore that does not expire? or have any other solutions?
Thanks in advance.
Shaun Brierly
whoops, forgot the - infront of cp... i'm fine
SHaun
22 years ago
Thanks for the reply!
I made the shortcut, and javaw is located in windows\System32... ok so I added -cp {myclasspath}... However I'm still getting the class not found error... any ideas? Thanks

Shaun
22 years ago
Hello,
This is a similar question, so I'll just use this topic instead of creating a new one.
I have my Jar working fine, however my Application needs to have some System Properties set, with the -D option. Anyone know how to do this, and still have it so you can simply double click the .jar in windows?
Thanks.
22 years ago
I'll have to try that, thanks =D
Shaun
22 years ago
How do you do this?.. for instance, the user presses a certain key and the Scrollpane will scroll...
Thanks
22 years ago
Thanks for reply, I looked further into it. There are actually two connections. One is a regular socket, and the other is a datagramsocket which passes UDP packets. They're both closed at the same point in the program. It seems to be some conflict with the DatagramSocket class and linux, because once again, it works in windows, but not linux. So still have the same problem, where when someone refreshes the browser, or reloads in Appletviewer it gives the Address already in use exception.
Shaun.