Showing the content of a file in an effective way

Hi all, I am in a novice level in Java and all i want is to recieve the content of a text file.
Here is my code
import java.io.*;
public class FileReader
public static void main(String[] args)
throws IOException
FileInputStream theFile=
new FileInputStream("text.txt");
FilterInputStream myfile=
new FilterInputStream(theFile);
int c;
while ((c = myfile.read()) != -1)
{System.out.print(c);}
theFile.close();
The Error
D:\java\Java3d Project\FileReader.java:12: FilterInputStream(java.io.InputStream) has protected access in java.io.FilterInputStream
new FilterInputStream(theFile);
^
1 error
What is wrong? I want to be able to chack whether the "1" in my text file is integer or not.
Thanks in advance

Here is my code then
import java.io.*;
public class FileReader
public static void main(String[] args)
throws IOException
FileInputStream theFile=
new FileInputStream("text.txt");
BufferedInputStream myfile=
new BufferedInputStream(theFile);
String c=new String();
while ((c = myfile.readLine()) != -1)
{System.out.print(myfile);}
theFile.close();
The Error
D:\java\Java3d Project\FileReader.java:16: cannot resolve symbol
symbol : method readLine ()
location: class java.io.BufferedInputStream
while ((c = myfile.readLine()) != -1)
^
D:\java\Java3d Project\FileReader.java:16: operator != cannot be applied to java.lang.String,int
while ((c = myfile.readLine()) != -1)
^
2 errors
What have i done wrong? Is there any relevant issue?
My target is to read the file text.txt which has its data in a well-structured manner. That means if i look in the beginning of each line then the first character must be integer. I want my program to determine if the particilar character in my text.txt is integer or not.

Similar Messages

  • From browse button of input type=file, can I show the content of a file

    Hi all,
    I am using, input type=file, where browse button appears. I am having a text area. My requirement is after I select the browse button, I need to show the content of the file in the text area. As of now I 've handled by having another button 'show', which should be pressed after browse done. But, How to handle it in the browse button itself, how will I get that action event from browse button. Plz help.
    Regards,
    Sam

    I think someone asked a very similar question here,
    http://forum.java.sun.com/thread.jsp?forum=45&thread=501889
    check the thread, it may help you.
    -S-

  • FILE UPLOAD PROBLEM SHOWING THE CONTENTS IN THE SAME BROWSER WINDOW

    Hi,
    This is amit Joshi
    I have uploaded content using input tag of type file and posted to jsp as multipart/form-data type
    in that jsp i am using following code to display the content in browser but only first content is displayed How can i modify it to show all content in the file ..
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
    FileItem fileItemTemp = (FileItem)it.next();
    if (fileItemTemp.isFormField()){
    %>
    <b>Name-value Pair Info:</b>
    Field name: <%= fileItemTemp.getFieldName() %>
    Field value: <%= fileItemTemp.getString() %>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
    optionalFileName = fileItemTemp.getString();
    else
    fileItem = fileItemTemp;
    if (fileItem!=null){
    String fileName = fileItem.getName();
    %>
    <b>Uploaded File Info:</b>
    Content type: <%= fileItem.getContentType() %>
    Field name: <%= fileItem.getFieldName() %>
    File name: <%= fileName %>
    <%
    if(fileItem.getContentType().equals("image/jpeg")) { %>
    File : <p><%
         //response.setContentType("image/gif");
         byte[] bArray=fileItem.get();
         response.setContentType("image/jpeg");
         outputStream=null;
         outputStream= response.getOutputStream();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    else if(fileItem.getContentType().equals("text/plain"))
         %> File : <%= fileItem.getString() %>
    <%
    byte[] bArray=fileItem.get();
    response.setContentType("text/plain");
         outputStream = response.getOutputStream();
         out.println();
         outputStream.write(bArray);
         outputStream.flush();
         outputStream.close();
    %> </p> <%
    %>
    </body>
    </html>
    Edited by: Amit_Joshi on Nov 13, 2007 10:58 PM

    Well Well Well..
    That would not work...
    What you have to do is save the uploaded file content on to a location and then pass the fileName as a request parameter to a deidicated which displays the contents of that file.
    Just as an example
    <html>
    <head>
    <title>File Upload Display</title>
    </head>
    <body>
    <%
    //ServletOutputStream sout=response.getOutputStream();
    StringBuilder strBuilder = new StringBuilder();
    int count=0;
    String f;
    f=request.getParameter("filedb");
    DBManager dbm = new DBManager();
    //dbm.createTable("mms3");
    //log.info("In JSP : "+ f);
    //dbm.insert_data(f,"mms3");
    %>
    <%
    if (ServletFileUpload.isMultipartContent(request)){
    ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
    List fileItemsList = servletFileUpload.parseRequest(request);
    strBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append('\r').append('\n').append("<xpage version=\"1.0\">").append('\r').append('\n');
    String optionalFileName = "";
    FileItem fileItem = null;
    Iterator it = fileItemsList.iterator();
    ServletOutputStream outputStream=null;
    while (it.hasNext()){
       FileItem fileItemTemp = (FileItem)it.next();
    %>
    Name-value Pair Info:
    Field name: <%= fileItemTemp.getFieldName() %><br/>
    Field value: <%= fileItemTemp.getString() %><br/>
    <%
    if (fileItemTemp.getFieldName().equals("filename"))
        optionalFileName = fileItemTemp.getString();
    if(!fileTempItem.isFormFiled()){
       String fileName = fileItem.getName();
       fileItem.write(optionalFileName);
    %>
    Uploaded File Info:
    Content type: <%= fileItem.getContentType() %><br/>
    Field name: <%= fileItem.getFieldName() %><br/>
    File name: <%= fileName %><br/>
    <%
    if(fileItem.getContentType().equals("image/jpeg") || fileItem.getContentType().equals("image/pjeg")) {
    %>
      <img src="FileServlet?fileName=<%=optionalFileName%>"   
    <%
    %>
    </body>
    </html>a sample code snippet for FileServlet.
    String fileName =  request.getParameter(fileName);
      File file = new File(fileName);
       if(!file.exists())
         return;
      // If JSP
      String mimeType = application.getMimeType("fileName");
           If you are using servlet
           String mimeType = this.getServletContext().getMimeType(fileName);
         response.setContentType(mimeType);  
         response.setHeader("Content-Disposition","inline;filename=\\"+fileName+"\\");
      BufferedOutputStream out1 = null;
      InputStream in = null;
      if(mimeType == null)
         mimeType = "application/octet-stream";
      try{
         in = new FileInputStream(f);
         response.setContentLength(in.available());
         BufferedOutputStream out1 = new BufferedOutputStream(response.getOutputStream(),1024);
         int size = 0;
         byte[] b = new byte[1024];
         while ((size = in.read(b, 0, 1024)) > 0)
            out1.write(b, 0, size);
      }catch(Exception exp){
      }finally{
          if(out1 != null){
             try{
                out1.flush();               
                out1.close();
             }catch(Exception e){}
          if(in != null){
            try{in.close();}catch(Exception e){}
      } Hope that might answer your question :)
    However,this is not the recommended way of doing this make use of MVC pattern.Would be a better approach.
    you might think of googling on this and can findout what is the best practise followed for problems of this sort
    REGARDS,
    RaHuL

  • My I-Pad screen is black, I tried to sync and restore I-Pad, it showes the contents on the computer and pulling out pictures and other files, but screen is black. what can I do?

    My I-Pad screen is black!! I tried to sync and restore I-Pad, it showes the contents on the computer and pulling out pictures and other files, but screen is black. I don't know what happened! what can I do?

    I have this problem as well...however, resetting/restoring did not take place when I followed the same instructions but got nothing on the screen.  Thanks in advance.

  • How to display the content from a file  stored in database

    when i am trying to display the content from a file which stored in database on oracle report 10g
    data are displaying as following. please help me to display the data in readable format
    <HTML LANG="en-US" DIR="LTR">
    <!-- Generated: 1/11/2006, postxslt.pl [1012] v1
    Source: amsug304286.xml
    File: amsug304286.htm
    Context: nil
    Tiers: ALWAYS
    Pretrans: YES
    Label: Release 12 -->
    <HEAD>
    <!-- $Header: amsug304286.htm 120.4 2006/11/01 20:57:29 appldev noship $ -->
    <!--BOLOC ug1_OMPO1010302_TTL--><TITLE>Product Overview (ORACLE MARKETING)</TITLE><!--EOLOC ug1_OMPO1010302_TTL-->
    <LINK REL="stylesheet" HREF="../fnd/iHelp.css">
    </HEAD>
    <BODY BGCOLOR="#F8F8F8">
    <A NAME="T304286"></A><A NAME="ProdOve"></A>
    <CENTER><H2><!--BOLOC ug1_OMPO1010302--><B>Product Overview</B><!--EOLOC ug1_OMPO1010302--></H2></CENTER>
    <p><!--BOLOC ug1_OMPO1010304-->Oracle Marketing drives profit, not just responses, by intelligently marketing to the total customer/prospect base. By leveraging a single repository of customer information, you can better target and personalize your campaigns, and refine them in real time with powerful analytical tools.<!--EOLOC ug1_OMPO1010304--></p>
    <p><!--BOLOC ug1_OMPO1006611-->With tools necessary to automate the planning, budgeting, execution, and tracking of your marketing initiatives, Oracle Marketing provides you with:<!--EOLOC ug1_OMPO1006611--></p>
    <ul>
    <li>
    <p><!--BOLOC ug1_OMPO1006612--><B>Customer Insight</B> - With sophisticated customer management and list generation, Oracle Marketing enables you to quickly generate target lists and segments using an intuitive user interface. The easy to use Natural Query Language Builder (NLQB) lets you query for customers or prospects using a natural language while hiding data complexity; fatigue management ensures that you do not over-contact the same customers with marketing messages; and predictive analytics helps you predict customer behavior that you can leverage to produce significant increases in marketing return on investments (ROI).<!--EOLOC ug1_OMPO1006612--></p>
    </li>
    <li>
    ls.<!--EOLOC ug1_OMPO1010304--></p>
    <p><!--BOLOC ug1_OMPO1006611-->With tools necessary to automate the planning, budgeting, execution, and tracking of your marketing initiatives, Oracle Marketing provides you with:<!--EOLOC ug1_OMPO1006611--></p>
    <ul>
    <li>
    <p><!--BOLOC ug1_OMPO1006612--><B>Customer Insight</B> - With sophisticated customer management and list generation, Oracle Marketing enables you to quickly generate target lists and segments using an intuitive user interface. The easy to use Natural Query Language Builder (NLQB) lets you query for customers or prospects using a natural language while hiding data complexity; fatigue management ensures that you do not over-contact the same customers with marketing messages; and predictive analytics helps you predict customer behavior that you can leverage to produce significant increases in marketing return on investments (ROI).<!--EOLOC ug1_OMPO1006612--></p>
    </li>
    <li>
    <p><!--BOLOC ug1_OMPO1006613--><B>Sales Alignment</B> - Oracle Marketing's leads management helps you compile and distribute viable leads so that sales professionals can follow up valuable opportunities and not just contact interactions. Additionally, support for distributing proposals and marketing material drive speedy and consistent setups and collaboration of best practices.<!--EOLOC ug1_OMPO1006613--></p>
    </li>
    <li>
    <p><!--BOLOC ug1_OMPO1006614--><B>Marketing Insight</B> - While Oracle Marketing Home page reports and Daily Business Intelligence (DBI) for Marketing and Sales provide aggregated management level information in almost real time, operational metrics help in tracking the effectiveness of individual marketing activities.<!--EOLOC ug1_OMPO1006614--></p>
    </li></ul>
    </BODY>
    </HTML>
    <!-- Q6z5Ntkiuhw&JhsLdhtX.cg&Zp4q0b3A9f.&RQwJ4twK3pA (signum appsdocopis 1162406236 2673 Wed Nov 1 10:37:16 2006) -->

    Hi,
    you can try to use the:
    <b>ConsumerTreeListPreview</b>
    layout for KM navigation ivew (or customize to your own).
    This layout shows a folder tree on the left, a document list on the right. When you click on a document from the list it shows the contents of the file on the bottom of the iview.
    Hope this helps,
    Romano

  • How to display the content of a file in the portal?

    Hey guys, could anyone help?
    I just created a page which includes two iView, one is KM Navigation iView to display a certain repository, while the other is for displaying the content of a certain file I click in the navigation iView.
    And now the problem is when I click a file in the KM Navigation iView, it will pop up a new window to display it. How can I make it displayed in a fixed iView, which type of this iView should be?

    Hi,
    you can try to use the:
    <b>ConsumerTreeListPreview</b>
    layout for KM navigation ivew (or customize to your own).
    This layout shows a folder tree on the left, a document list on the right. When you click on a document from the list it shows the contents of the file on the bottom of the iview.
    Hope this helps,
    Romano

  • Is it possible to display the content of a file in flex as it is written. E.G. a log file

    I have flex app sitting on a Linux server.
    I want to be able to spool the content of a file on the same server as the flex app to the users screen using say a textarea or similar.
    The file is some type of log so its going to constantly have lines added. Is there a way to do this ? I am guessing I need to constantly refresh the flex app with the file content.

    Yes you can. Small example for you:
    [email protected]> select * from dept;
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    [email protected]> alter session set cursor_sharing=force;
    Session altered.
    [email protected]> alter session set events '10046 trace name context forever, level 12';
    Session altered.
    [email protected]> select * from dept where deptno = 20;
    DEPTNO DNAME LOC
    20 RESEARCH DALLAS
    [email protected]> exit
    Trace file:
    PARSING IN CURSOR #3 len=44 dep=0 uid=68 oct=3 lid=68 tim=110240041190 hv=3378028910 ad='7b0b0ca0'
    select * from dept where deptno = :"SYS_B_0"
    END OF STMT
    PARSE #3:c=0,e=28847,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=0,tim=110240041185
    BINDS #3:
    bind 0: dty=2 mxl=22(02) mal=00 scl=00 pre=00 oacflg=10 oacfl2=100 size=24 offset=0
    bfp=06f04688 bln=22 avl=02 flg=09
    value=20
    EXEC #3:c=0,e=19767,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=110240071912
    WAIT #3: nam='SQL*Net message to client' ela= 5 p1=1111838976 p2=1 p3=0
    WAIT #3: nam='db file sequential read' ela= 13920 p1=23 p2=72274 p3=1
    FETCH #3:c=0,e=29325,p=1,cr=2,cu=0,mis=0,r=1,dep=0,og=4,tim=110240105613
    WAIT #3: nam='SQL*Net message from client' ela= 248 p1=1111838976 p2=1 p3=0
    FETCH #3:c=0,e=2,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,tim=110240111496
    WAIT #3: nam='SQL*Net message to client' ela= 2 p1=1111838976 p2=1 p3=0
    WAIT #3: nam='SQL*Net message from client' ela= 1361188 p1=1111838976 p2=1 p3=0
    The interesting line for you
    BINDS #3:
    bind 0: dty=2 mxl=22(02) mal=00 scl=00 pre=00 oacflg=10 oacfl2=100 size=24 offset=0
    bfp=06f04688 bln=22 avl=02 flg=09
    value=20
    Which shows you that :"SYS_B_0" was subsituted with value equal 20
    Best Regards
    Krystian Zieja / mob

  • Read the content of a file (via socket)

    Hi,
    I need to read the content of a file (.txt, or better, .jpg) and to write it again in another file.
    I have this code (in Javascript):
        conn = new Socket;
        conn.encoding = "BINARY";
        if (conn.open ("127.0.0.1:8888")) {
        conn.timeout=30;
        conn.writeln("GET variousFiles/file.jpg HTTP/1.1");
        reply = conn.read(999999);
        conn.close();
        var file = new File("C:/APPS/New_File.txt");
        file.encoding = 'BINARY';
        var open_file = file.open("w+");
        file.write(reply);
        } else { alert("Errore: " + conn2.error); }
    However my new file is always empty, because I can not read the content of the first file.
    My variable "reply" is always empty.
    Thanks and best regards.

    There is a particular case with sugested function, if content is generated on the fly by the server -php, cgi, etc.-
    In this case, http server doesn´t knows total size of response data, so response shows a chunked transfer-encoding header and data is parted in chunks, each one starting with it´s size, and following the data.
    HTTP/1.1 200 OK
    Date: Tue, 30 Apr 2013 12:43:41 GMT
    Server: Apache/1.3.31 (Win32) mod_fastcgi/2.4.1
    Connection: close
    Transfer-Encoding: chunked
    Content-Type: image/jpeg
    f49
    ÿØÿà  JFIF
    I´m using this function to decode parted response, with initial chunkedString with firs chunk size; in this case, f49:
    PartsSeparator="\r\n";
    function getPartedBody(partedBodyString) {
        var separatorPosition=partedBodyString.indexOf(PartsSeparator);
        var chunkSize=new Number("0x"+partedBodyString.substring(0,separatorPosition));
        separatorPosition+=PartsSeparator.length;
        var bodyString=new String("BINARY");
        bodyString="";
        if (chunkSize>0)
            bodyString=partedBodyString.substring(separatorPosition,separatorPosition+chunkSize)+
                getChunkedResponse(partedBodyString.substring(separatorPosition+chunkSize+PartsSeparator. length));
        return bodyString;
    Hope this helps
    regards

  • How do i "show package contents" on .webtemplate files that have arrow

    Hi,
    Quick question:
    How do i "show package contents" on .webtemplate files that have a small arrow attached on the file icon. Its a template a downloaded from 11mystics.com (free). When i right click the icon there is no "show package contents" available on the drop down menu....
    Thanx!

    When you bring up the contextual menu for the icon, choose "Show Original". This will take you to where the original file is and you should be able to "Show Package Contents" on it.

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • I have one out of five email address's with coxmail that opens with a blank inbox but other browsers show the content of the same inbox

    Question
    I have one out of five email address's with coxmail that opens with a blank inbox. Other browsers like opera or IE show the content of the same inbox. I've contacted cox but they tell me the problem is on my computer. I've used three different anti virus/malware scanners to eliminate all the bugs they can find. I need a firefox guru with suggestions. Thanks, Charles

    You can undo your permission changes. Probably the most relevant one is cookies. Try one or both of these methods:
    (1) Page Info > Permissions tab
    While viewing a page on the site:
    * right-click and choose View Page Info > Permissions
    * Alt+t (open the classic Tools menu) > Page Info > Permissions
    (2) about:permissions
    In a new tab, type or paste '''about:permissions''' and press Enter. Allow a few moments for the list on the left to populate, as this information needs to be extracted from a database.
    Then type or paste ''rcn''' in the search box above the list to filter it to the most relevant domains. When you highlight a domain, you can adjust its permissions in the right pane.
    Any luck?

  • How to show the content of a table (long text) in a scrollable textbox?

    Hi,
    I have to say first, many thanks to the ones who answers to threads in this forum, it's very helpfull when we're learning web dynpro!
    I have a RFC function that return a table containing a long text (node "it_text", with elements "Tdformat" and "Tdline").
    1) I want first to copy all the Tdlines in a new node "text_box" (that I made specially for the screen, it contains only the element "Tdline" [the text itself]);
    2) Then I want to show the content of the node "text_box" in a scrollable textbox on the screen (to show 8 lines of text, for example).
    How to do that easily?  What is the UI Element needed to show that?
    Thanks!

    If you want to display as it is then you can use Table UI element. You can change the design property to 'transparent' and set column header visibility property to none. Then you need not to write any code simple you can map the node to table field.
    Even with TextEdit you can achieve what you want. Try this code...
         StringBuffer tmpBuffer = new StringBuffer();
         for(int index=0;index<wdContext.nodeLines().size();index++)
              wdContext.nodeLines().setLeadSelection(index);
              tmpBuffer.append(wdContext.currentLinesElement().getLine()+"n");
         wdContext.currentContextElement().setData(tmpBuffer.toString());
    Regards
    Abhilash

  • How To Fetch the Content of a File from Client's PC?

    In my JSP I have this:
         <input type="file" name="filename">for visitors of the web page to browse their PCs' directories to select a file to upload (when the Submit button is clicked).
    What appears in the text field will be a file name. How do I get both the file name and the content of that file to be saved in the database?

    From http://www.htmlhelp.com/reference/html40/forms/input.html:
    A form that includes a file INPUT must specify METHOD=post and ENCTYPE="multipart/form-data" in the <FORM> tag. CGI libraries such as CGI.pm allow simple handling of such forms.
    Form-based file upload is unsupported by many currently deployed browsers. Authors should provide alternative methods of input where possible.
    The following example allows the user to upload an HTML document for validation:
    <FORM METHOD=post ACTION="/cgi-bin/validate.cgi" ENCTYPE="multipart/form-data">
    <P>Select an HTML document to upload and validate. If your browser does not support form-based file upload, use one of our alternate methods of validation.</P>
    <P><INPUT TYPE=file NAME="html_file" ACCEPT="text/html"></P>
    <P><INPUT TYPE=submit VALUE="Validate it!"></P>
    </FORM>
    Your servlet would then have to process whatever data is put into that parameter. You can look at O'Reilly's servlet utilities, or one of the other other links here:
    http://www.google.com/search?q=java+servlet+file+upload&sourceid=opera&num=0&ie=utf-8&oe=utf-8

  • How to store the contents of a file

    Hi,
    I'm using forms6i and database 10g.
    Through forms if a user selects a filename , and clicks a button or something,
    the contents of the file should be saved in the database.
    The file can be of any type, like .doc,.pdf,.xml,.html etc...
    and the contents filed will be of type varchar
    Please help me do this..
    Thanks

    Do you really want to save the "Content" of a file or the file itself? If you try to save the contents of a .doc or .pdf in a column with a VARCHAR2 datatype, you are going to corrupt the contents of the file since these file types have binary data in them as well as text. I think you would have greater success storing the actual file in a BLOB column.
    Here are a few Oracle Support documents that discuss how to store and retrieve files stored as BLOBs in the database.
    Doc ID: 168277.1 - How to Upload Binary Documents Back to Database BLOB Column from Forms
    Doc ID: 330146.1 - How to write BLOBs Stored Inside the Database Out to Files.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to save the contents of a file(not a text file)

    Hi all, I want to save the contents of a file(,png file, not a text file) as a field in a class. Shall I have it as a string or byte array or something?
    I have tried saving a file in a string but there were some problems with loading the file from a different platform. Following is my code.
            String string;
            try {
                StringBuffer sb = new StringBuffer(1024);
                char[] characterArray = new char[1024];
                BufferedReader br = new BufferedReader(new FileReader(file));
                while(br.read(characterArray) != -1){
                    sb.append(String.valueOf(characterArray));
                br.close();
                string= sb.toString();
            } catch (IOException ex) {
                ex.printStackTrace();
            }and I use the following code to recover the string back to a stream, and save that stream back to a time later.
        ByteArrayInputStream bais = new ByteArrayInputStream(map.getBytes());I realized that because this file is not a text file, the string could cause some problems. But anyone could tell me if I should use a byte array or someting? and how?
    Any help would be appreciated!
    Cheers,
    Jing

    You should use a byte array, and the binary streams (InputStream a& OutputStream). Never use Strings and Reader/Writer if you have binary data.
    Kaj

Maybe you are looking for

  • PROBLEM WITH ALT-V WHEN USING CROATIAN KEYBOARD

    Hi, When Typing ALT GR+V (@ sign) in Croatian Keyboard, all the text from clipboard is copied into the text box (as it is pressed CTRL+V) plus the @sign. There were some bugs filed long back regarding a similar issue for the German keyboard where the

  • Dell XPS Touchpad Driver No Longer Working in Build 10041. Was fine with Build 9926

    First of this is an old Dell, but from Vista through to Windows 8.1 Update, and then the initial Windows 10 Tech Preview Builds the Mouse Drivers have been OK. Its not so much the core mouse driver, but the feature extensions in the Accompanying driv

  • Bapi upload of service pr data

    Hi Experts, I am new to bapi and am uploading service pr data using bapi while updating program is activated but data is not updating, in debugging it comes errors like this,   LPR0000002 instance of object type purchase requisation has been created.

  • Import Problem (maybe trivial)

    Hello, I'm trying to import a dump (only one schema) and get the following conversation: IMP-00017: following statement failed with ORACLE error 4068: "BEGIN SYS.DBMS_REPCAT_MIG.PRE_IMPORT; END;" IMP-00003: ORACLE error 4068 encountered ORA-04068: ex

  • Wpf graph Measurement studio

    Bonjour, Je vous expose mon  probleme. J'ai developpe une application  sous Win7 et VS2010 environnement C# et wpf. Je dois afficher une courbe en temps réel sur une periode d'une heure avec un nouveau point toutes les 100ms (soit max 36000). J'utili