[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

read file + write file = copy file

Posted on 2003-10-30
2
Medium Priority
?
18,449 Views
Last Modified: 2012-05-04
hi, im trying to read a contents of a file (from a class), store it in a variable/object and pass it to another class and that other class will write it to a file. now im stuck at reading the contents of the file and passing it to another class, ive tried using byte[] as the datatype (i think thats the problem), but it doesnt work. what other datatypes can i use? assuming that the file could be anything (.jpg, .mp3, .zip, etc, etc). what other datatype can i use and how to use them to read/write?
thanks

0
Comment
Question by:Traltixx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:RobertMarkBram
ID: 9655423
Can you post some code for us to look at?

Usually, reading byte from a file when you don't know the type of file is probably the best way to do it...

Are you getting an exception or something?

Rob
:)
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 75 total points
ID: 9655521

     FileInputStream YourInputStream=new    FileInputStream(YourReadFile);
     File f=new File(YourReadFile);
     byte b[]=new byte[f.length()];
     YourInputStream.read(b);
     B b1=new B();
     b1.write(b,"Your Out Put File");
   //and other codes

where you need to write method in class B and bla bla bla

And I say you are going in right way only. You should use byte array only for reading binary files.

Cheers

0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question