svn-gvsig-desktop / trunk / libraries / libCompatMobile / src / org / gvsig / compat / FileUtils.java @ 20070
History | View | Annotate | Download (2.48 KB)
1 |
package org.gvsig.compat; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.FileInputStream; |
5 |
import java.nio.ByteBuffer; |
6 |
import java.nio.channels.FileChannel; |
7 |
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
9 |
*
|
10 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
|
11 |
*
|
12 |
* This program is free software; you can redistribute it and/or
|
13 |
* modify it under the terms of the GNU General Public License
|
14 |
* as published by the Free Software Foundation; either version 2
|
15 |
* of the License, or (at your option) any later version.
|
16 |
*
|
17 |
* This program is distributed in the hope that it will be useful,
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
* GNU General Public License for more details.
|
21 |
*
|
22 |
* You should have received a copy of the GNU General Public License
|
23 |
* along with this program; if not, write to the Free Software
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
25 |
*
|
26 |
* For more information, contact:
|
27 |
*
|
28 |
* Generalitat Valenciana
|
29 |
* Conselleria d'Infraestructures i Transport
|
30 |
* Av. Blasco Ib??ez, 50
|
31 |
* 46010 VALENCIA
|
32 |
* SPAIN
|
33 |
*
|
34 |
* +34 963862235
|
35 |
* gvsig@gva.es
|
36 |
* http://www.gvsig.gva.es
|
37 |
*
|
38 |
* or
|
39 |
*
|
40 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
41 |
* Conde Salvatierra de ?lava , 34-10
|
42 |
* 46004 Valencia
|
43 |
* Spain
|
44 |
*
|
45 |
* +34 963 510 612
|
46 |
* +34 963 510 968
|
47 |
* gis@prodevelop.es
|
48 |
* http://www.prodevelop.es
|
49 |
*
|
50 |
* or
|
51 |
*
|
52 |
* Instituto de Rob?tica
|
53 |
* Apartado de correos 2085
|
54 |
* 46071 Valencia
|
55 |
* (Spain)
|
56 |
*
|
57 |
* +34 963 543 577
|
58 |
* jjordan@robotica.uv.es
|
59 |
* http://robotica.uv.es
|
60 |
*
|
61 |
*/
|
62 |
/* CVS MESSAGES:
|
63 |
* -------------
|
64 |
* $Id$
|
65 |
* $Log$
|
66 |
*
|
67 |
*/
|
68 |
/****************************************************************
|
69 |
* *
|
70 |
* PRODEVELOP S.L. *
|
71 |
* @author Carlos S?nchez Peri??n (csanchez@prodevelop.es) *
|
72 |
* *
|
73 |
****************************************************************/
|
74 |
public class FileUtils { |
75 |
|
76 |
public static byte[] readFile(File f){ |
77 |
byte[] data = null; |
78 |
try{
|
79 |
FileInputStream fis = new FileInputStream(f); |
80 |
FileChannel fc = fis.getChannel();
|
81 |
data= new byte[(int)fc.size()]; // fc.size returns the size of the file which backs the channel |
82 |
ByteBuffer bb = ByteBuffer.wrap(data); |
83 |
fc.read(bb); |
84 |
} catch (Exception e){ |
85 |
|
86 |
} |
87 |
return data;
|
88 |
} |
89 |
} |