|
-
Jul 30th, 2001, 05:37 AM
#1
Thread Starter
Member
Reading data from file
I am trying to read a certain ammount of bytes from a file and write it to anouther file. The certain amount of bytes in not always the same. Here the number of bytes is stored in NewSize which is a long. The name of the new file is in Name, string. An error occurs saying '.class' is expected and point to buffer[] on this line:
c = in.read(buffer[], y, (int) NewSize - 1);
It seems to think buffer[] is a class??
Also the compiler does not like anything to do with the out, out.close() expects an extra ')' at the end, the out.write(buffer[].length); causes a 'cannot resolve symbol?
--------
int x, c;
int y = 0;
byte buffer[];
//All this is in a try/catch
InputStream in = new FileInputStream(FilePath);
c = in.read(buffer[], y, (int) NewSize - 1);
if (c != -1) {
OutputStream out = new FileOutputStream(Name);
out.write(buffer[].length);
out.close();
}
-
Aug 8th, 2001, 05:53 PM
#2
Dazed Member
-
Aug 10th, 2001, 12:18 AM
#3
Thread Starter
Member
Yes thank you, your stream copier helped, and also I found that when you create a byte array, byte buffer[], you also have to say what size of you want the array, byte buffer[] = new byte[10];
then in the rest of the code you just refer to buffer, not buffer[].
-
Aug 10th, 2001, 07:33 AM
#4
Dazed Member
Cool. I was just curious to see if it worked.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|