FileInputStream and FileOutputStream are useful for writing to and reading from files in Java. The streams can be passed to any method that requires an InputStream or OutputStream, respectively.
These streams are classified as mode streams as they read and write data from disk files. the classes associated with these streams have constructos that allows us to specify the path of the file to which they are connected. The FileInputStream class allows us to read input from a file in the form of a stream. The FileOutputStream class allows us to write output to a file stream. Example, FileInputStream inputfile = new FileInputStream ("Empolyee.dat"); FileOutputStream outputfile = new FileOutputStream ("binus.dat");
FileReader used to read the character stream in the file.i.e a file that contanis only the character means FileReader is the choice to read the file.On the other hand if the file contains image,byte like raw data format means FileInputStream is the choice to read the data in the file,.
The Apache POI project is a Java API to read and write Microsoft Documents.The API allows you can read and write MS Excel files using Java.
First of all, these two classes are on different levels of abstraction. An InputStream is used for reading any stream of bytes, while a FileReader is used to read characters from a file. If you want to ask between a FileInputStream and a FileReader, then we need to look at what type of data you are reading. If you're reading plain-text file, for example, you want to use a FileReader because it was designed to read in characters. For other types of data, the FileInputStream would be better, as it is used to read in generic streams of bytes from a file.
import java.io.*; class Files { public static void main(String a[])throws IOException { int i,line=0,c=0,len; char k; boolean m; File f=new File("info.txt"); FileInputStream f1=new FileInputStream("info.txt"); len=f1.available(); for(i=0;i<=len;i++) { k=(char)f1.read(); c++; System.out.print(k); if(k='/n') { line++; System.out.println(+line); } } System.out.print("number of characters="+c); } }
I dont know you are looking for write new program to compress the data.. I am providing code to zip the file in Java.ZipOutputStream zipOutStream = new ZipOutputStream( new BufferedOutputStream( new FileOutputStream( ZipFileName )) );BufferedInputStream bufferInStram = new BufferedInputStream( new FileInputStream(FileToXip), 2000 );ZipEntry entry = new ZipEntry( excelFileName );zipOutStream.putNextEntry( entry );
It may be:He uses a hammer to build a birdhouse. (uses = verb)A hammer has many uses. (uses = plural noun)
4.0L uses 10w304.7L uses 5w304.0L uses 10w304.7L uses 5w30
Algeria uses the Algerian Dinar Bahrain uses the Bahrain DinarIraq uses the Iraqi DinarJordan uses the Jordanian DinarKuwait uses the Kuwaiti Dinar
Here's the code for inserting image into ms-access database <%@page import="java.io.FileInputStream"%><%@page import="java.io.IOException"%><%@page import="java.io.InputStream"%><%@page import="java.io.File"%><%@page import="javax.servlet.*"%><%@page import="javax.servlet.ServletException" %><%@page language="java" import="java.sql.*"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body><% FileInputStream fIn=null; Connection conn = null; PreparedStatement ps=null; String filename=request.getParameter("fileName"); File f=new File(filename); String filepath=f.getAbsolutePath(); try { // First, open a file for input. fIn = new FileInputStream(filepath); //InputStream is=new FileInputStream(filepath); /*..................Loading Driver.............*/ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); /*----------Establishing Connection-----------*/ conn=DriverManager.getConnection("jdbc:odbc:mydatabase"); ps=conn.prepareStatement("insert into fileupload values(?)"); ps.setBinaryStream(1,fIn,(int)f.length()); ps.executeUpdate(); conn.close(); out.println("file submitted sucessfully"); } catch(Exception e) { out.println(e); } %> </body></html>
The uses of what?
No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.No country in Asia uses the Euro.