How to write array list to file ?

Hi everyone,
I got a arraylist binaryEncodedData and I want to write to file. how do I make it into a HexString ? I had tried to convert it this way and it doesn't work. I try to print out the temp value but there was nothing . Please help, thanks
byte[] bytes = new byte[binaryEncodedData.size()];
String temp;
for(int i=0;i<binaryEncodedData.size();i++)
     bytes[i] = (byte)binaryEncodedData.get(i);
for(int i=0;i<bytes.length;i++)
     //System.out.println(Integer.toHexString(bytes[i] & 0X00FF));
     temp.concat(Integer.toHexString(bytes));
System.out.println("Temp = " + temp);

Strings are immutable. The correct way to get anything to print out is this:
for(int i=0;i<bytes.length;i++)
//System.out.println(Integer.toHexString(bytes & 0X00FF));
temp = temp.concat(Integer.toHexString(bytes));
}I'm not sure why you want this in Hex, but if it is not a requirement standard serialization would be easier.

Similar Messages

  • How to write to a log file within a JSP

    Hello everybody,
    do you know how to write to a log file within a JSP.
    my code is (/space/SP/tlf/ExcepcionJava.jsp):
    <html>
    <body bgColor=#C4E1FF>
    <%@ page import="java.io.*" %>
    <%
         FileWriter salida = new FileWriter(response.encodeURL("log.txt"));
         salida.write(request.getParameter("errorMsg"));
         salida.close();
    %>
    </body>
    </html>.. I run under Solaris, Jrun 2.3.3
    I have also test with getServletContext().getRealPath(), but I get /netsrv/nes/docs/ instead of /space/SP/tlf/

    Hi,
    Give the full path of the log file to the FileWriter. Such as;
    FileWriter salida = new FileWriter(response.encodeURL("/usr/local/tomcat/logs/testlogs/log.txt"));
    nurettin

  • How to write a Xml installation file to build  web installer using IzPack.

    Hai everyone,
    I have got a problem in building a web installer using IzPack.I am getting this exception,when I am compiling my install.xml using a compile tool provided by IzPack soft.Eventhough I have not mentioned "packsinfo.xml" in my Xml installation file.
    Fatal error :
    null\packsinfo.xml (The system cannot find the path specified)
    java.io.FileNotFoundException: null\packsinfo.xml (The system cannot find the path specified)
    What went wrong??
    It is very very urgent. Could anyone tell me how to write a Xml installation file for building web installer,please??
    any help will be highly appreciated....
    Thank you very much in advance

    Hi,
    that is not really a java related question. Have you tried to find some IzPack support forum? I've never heard about it, so I can't help.

  • How to write data to text file using external tables

    can anybody tell how to write data to text file using external tables concept?

    Hi,
    Using external table u can load the data in your local table in database,
    then using your local db table and UTL_FILE pacakge u can wrrite data to text file
    external table
    ~~~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
    UTL_FILE
    ~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
    Message was edited by:
    Nicloei W
    Message was edited by:
    Nicloei W

  • Sort array(list) of files on filename

    Hey all,
    Is there a way to sort an array(list) of files on the names of those files. (the files are not in same directory)
    Thanks

    Gogoe wrote:
    Hey all,
    Is there a way to sort an array(list) of files on the names of those files. (the files are not in same directory)
    Thanks
    Why do you need to sort the actual Files? Can't you just sort the list of name using Arrays.sort()? Once the names are in order you call up the Files in the order you read the names. Or is there more to the request yet?

  • How to write code for save file directory?

    how to write code for save file directory?

    how to find usa timezone code using java swing?
    i have some code help me
    public class ItsInitializer {
    private static boolean s_initialized = false;
    private ItsInitializer() {
    public static synchronized void initialize() {
    if (!s_initialized) {
    // Modifies default time zone, disables Daylight Saving Time.
    TimeZone l_defaultTimeZone = TimeZone.getDefault();
    int l_rawOffset = l_defaultTimeZone.getRawOffset();
    String l_id = l_defaultTimeZone.getID();
    SimpleTimeZone l_simpleTimeZone = new SimpleTimeZone(l_rawOffset,
    l_id,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0);
    TimeZone.setDefault(l_simpleTimeZone);
    s_initialized = true;
    2.
    long timeMillis = ...;
    long time = timeMillis / 1000;
    String seconds = Integer.toString((int)(time % 60));
    String minutes = Integer.toString((int)((time % 3600) / 60));
    String hours = Integer.toString((int)(time / 3600));
    for (int i = 0; i < 2; i++) {
         if (seconds.length() < 2) {
              seconds = "0" + seconds;
         if (minutes.length() < 2) {
              minutes = "0" + minutes;
         if (hours.length() < 2) {
              hours = "0" + hours;
    3.
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class Convert {
    public String getDateTime(String pattern){
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(new Date());
    * @param args
    public static void main(String[] args) {
    Convert con = new Convert();
    System.out.println(con.getDateTime("hh:mm:ss"));
    5.import java.text.SimpleDateFormat;
    import java.util.Date;
    public class Convert {
    public String getDateTime(String pattern){
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(new Date());
    * @param args
    public static void main(String[] args) {
    Convert con = new Convert();
    System.out.println(con.getDateTime("hh:mm:ss"));
    [ November 23, 2005: Mess
    private Locale locale = Locale.US;
    private static final String[] tzStrings = {
    "America/New_York",
    "America/Chicago",
    "America/Denver",
    "America/Los_Angeles",
    Date now = new Date();
    for ( TimeZone z : zones) {
    DateFormat df = new SimpleDateFormat("K:mm a,z", locale);
    df.setTimeZone(z);
    String result = df.format(now);
    System.out.println(result);
    String date="05/19/2008 04:30 AM (EST)";
                   SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm aaa (z)");
                   TimeZone.setDefault(TimeZone.getTimeZone("PST"));
                   long millis = sdf.parse(date).getTime();
                   sdf.setTimeZone(TimeZone.getDefault());
                   System.out.println(sdf.format(new Date(millis)));
    [ November 23, 2005: Mes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Anyone know how to write to a RAW file format?

    Hello,
    Been trying to find out if there is any way to write a RAW format file from an array containing pixel values? Do I just use a file writer and save as *.raw?
    Also, what information must I include beyond the pixel values?
    Thanks!

    Well, I had found those already and they weren't of
    too much help to my problem (how to actually create
    the RAW file), but thanks.I'd imagine that you'd create the RAW file according to the specifications provided. The links provided give you information as to the format of the RAW file. In order to actually create the RAW file, you'd simply spit out the properly-formed data to a file (see a tutorial such as "Lesson: I/O: Reading and Writing (but no 'rithmetic)" for more info, if needed).
    What additional help are you looking for?

  • How to write content of the file under folder

    Hi Experts,
    I have following scenario, I have list of files under folder in local desktop(for eg D:\mani)
    I have only filename, using this filename i want to search and get content of the particular file and write in some other location? how to do that? give your suggestions?
    Regards,
    P.Manivannan

    You could go two ways here:
    The first possibility requires that (a) you know what operating system you are working with, and (b) you only need to copy the file, and not do anything else with the contents of it. In this case, probably the easiest way to do this is to use a Runtime exec command for the file you want to copy:
    java.lang.Runtime.getRuntime().exec( "cp D:\mani D:\mani2" );Otherwise, if you need your code to be portable, you can't assume anything about the operating system. Since java.io.File doesn't provide a copy method, you will need to read the entire contents of the file into the vm, and then write them out to a new file. Also, if you need to use the contents of your file in some other way, as well, then you also need to read the entire contents into the vm. In this second case, how you read the file may depend on what kind of data the file contains.
    In general, the following code should work for you:
    final FileInputSteam  fis = new FileInputStream ( new File( "D:\mani"  ) );
    final FileOutputStream fos = new FileOutputStream( new File( "D:\mani2" ) );
    final byte [] buf = new byte[ 1024 ];
    int bytesRead;
    while ( ( bytesRead = fis.read( buf ) ) != 0 )
        fos.write( buf, 0, bytesRead );Don't forget to catch or throw IOException.
    Hope this helps.
    - Adam

  • Write array into txt file

    Hi Guys!
    I need a VI which writes the content of an array into a txt file.
    I have an array like this:
    Peti    Teri
    Zoli    Hajni
    Tomi    Heni
    Pali    Robi
    In the file the first line should be a full timestamp (date, time), and then would come the content of the array. The name of the file would also be a timestamp.
    Thank you for your help in advance!

    Hi Victronica and welcome to NI Forums!
    If you have some custom data, then it is up to ou to tell excel how to interpret said data (what information to put where, etc.) A simple solution would be to flatten your cluster elements into strings, and write those strings into an excel sheet using ActiveX. An example on how to write a table of strings is available in the example finder, and I also have it attached here in LabVIEW 2013.
    Kind regards:
    Andrew Valko
    National Instruments Hungary
    Attachments:
    Excel - Write Table.vi ‏17 KB

  • How to write LOGO to xls file.

    hi!
    i meet a case.
    user want to download sap list(generate using write command,not sap smartforms or sapscript)
        into xls file.
    but the sap list need contain a LOGO pic to display.
    so
    first:     how to create logo in sap list.
    second:how to download sap list into xls file in background.
    some know the reslove method! give me a idea! thank you very much!

    hi Gautham Vangaveti 
    Thank you your help!
    your mean i can use the function to wrirt logo to xls!
         CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
            EXPORTING
              FILE_NAME                       = path_and_file
      CREATE_PIVOT                    = 0
      DATA_SHEET_NAME                 = ' '
      PIVOT_SHEET_NAME                = ' '
      PASSWORD                        = ' '
      PASSWORD_OPTION                 = 0
           TABLES
      PIVOT_FIELD_TAB                 =
             DATA_TAB                        = excel_down
      FIELDNAMES                      =
           EXCEPTIONS
             FILE_NOT_EXIST                  = 1
             FILENAME_EXPECTED               = 2
             COMMUNICATION_ERROR             = 3
             OLE_OBJECT_METHOD_ERROR         = 4
             OLE_OBJECT_PROPERTY_ERROR       = 5
             INVALID_PIVOT_FIELDS            = 6
             DOWNLOAD_PROBLEM                = 7
             OTHERS                          = 8.
    but i don't know how to assign my logo to this funciton !
    can you provide some demo !
    thank you very much!

  • How to retrieve arrays from a file.

    If i were to save 5 arrays to a file like this.....
    DataOutputStream output;
         DataInputStream input;
         Date today = new Date();
         String filename = "phonebook";
    private String name[] = {""};
         private String surname[] = {""};
         private String home[] = {""};
         private String work[] = {""};
         private String cell[] = {""};
         try
                   output = new DataOutputStream(new FileOutputStream(filename));
              catch(IOException io)
                   JOptionPane.showMessageDialog(null,"This program could not create a storage location. Please check the disk drive and the tun the program again.","Error",JOptionPane.ERROR_MESSAGE);
                   System.exit(1);
    public void save()
              try
                   for(int i=0; i < name.length; i++)
                        output.writeUTF(name);
                        output.writeUTF(surname[i]);
                        output.writeUTF(work[i]);
                        output.writeUTF(home[i]);
                        output.writeUTF(cell[i]);
                   JOptionPane.showMessageDialog(null,"Data succesfully saved to file.","Information message",JOptionPane.INFORMATION_MESSAGE);
              catch(IOException io)
                   System.exit(1);
         }And then I want to use them again on my startup. How would I go about initialising them back into thier origianl arrays. What i mean is I want the arrays to contain theier previous saved values. Is this possible.
    I tried to do it like this but it wont work. I get no errors. It just wont return and strings at all.try
                   input = new DataInputStream(new FileInputStream(filename));
              catch(IOException io)
                   JOptionPane.showMessageDialog(null,"Could not find the correct file to read data from.","Error",JOptionPane.ERROR_MESSAGE);
              try
                   for(int i=0; i< name.length; i++)
                        name[i]=input.readUTF();
                        surname[i]=input.readUTF();
                        work[i]=input.readUTF();
                        home[i]=input.readUTF();
              cell[i]=input.readUTF();
              catch(IOException io)
              }Or is it better to create a seperate file for each array?
    Edited by: Yucca on Mar 23, 2008 2:24 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Any help here please.
    Edited by: Yucca on Mar 23, 2008 6:34 PM

  • How to get a list of files under C:\Program Files?

    dir C:\"Program Files" in DOS will get me a list of files in the directory. But how could I do in Java to get the some results? To put it in two double quotes, does not work.
    Any suggestions?

    Here is a small Java program that will read the contents of any directory for you:
    readDir.java
    ==========
    import java.io.*;
    public class readDir {
       public static void main(String[] args) {
          try {
             String[] dirArray=new File(args[0]).list();
             for (int i=0;i<dirArray.length;i++) System.out.println(dirArray[ i ]);
          } catch (Throwable exception) {
             exception.printStackTrace();
    }Just compile the program and run it as follows:
    java readDir "C:\Program Files"
    ;o)
    V.V.

  • How to read arrays from a file

    hi i was curious if i have a data file something like this
    34 12 10 5 4 3
    23 12 11 19 18
    42 32 23 12 11
    how can i read this data file and lines into three different arrays
    for example myArray1 should contain the first line which is 34 12 10 5 4 3 i am having alot of hard time.
         public static void main(String[] args) throws IOException
              int[] myArray = new int[10];
              //int[] myArray1 = new int[10];
              Scanner s = null;
              Tester2 test = new Tester2();
              try
                   s = new Scanner(
                        new BufferedReader (new FileReader("numbers.txt")));
                        while(s.hasNext())
                             if(s.hasNextInt())
                                  for(int i=0; i<myArray.length; i++)
                                  myArray[i] = s.nextInt();
                                  System.out.print(" "+myArray);
              finally
              { s.close();
    this things prints me the whole array

    lol you stupid fookks.
       try{
            BufferedReader bf=new BufferedReader(new FileReader("program1.txt"));
            String s=bf.readLine();
                String s1[]=s.split("\\s");
                int[] array1=new int[s1.length];
                for(int i=0;i<s1.length;i++)
                  array1=Integer.parseInt(s1[i]);
    s=bf.readLine();
    String s2[]=s.split("\\s");
    int[] array2=new int[s2.length];
    for(int i=0;i<s2.length;i++)
    array2[i]=Integer.parseInt(s2[i]);
    s=bf.readLine();
    String s3[]=s.split("\\s");
    int[] array3=new int[s3.length];
    for(int i=0;i<s3.length;i++)
    array3[i]=Integer.parseInt(s3[i]);
    kiss my asian a$$ you all think i am a dumb fok well you know what you have freakin attitude problems. i can do it on my own also you all dumb senior foks. i asked for help warnerja not for your stupid a$$ comments fok yuou.... i am not a freakin newbie just new to this file. stuff. thats all all i was doing was asking for help

  • How to write and read Xml file from database if possible?

    Hi all,
    I need to read the .Xml file when receives from Source systems and write the data into the table as well as write in the.xml file thru reading the data from table as per the client needs. I am stranger to this area. Since, please provide some examples how to approach the same.
    Thanks in advance !!
    Regards.
    Vissu.....

    The XML DB forum is better suited to your question.
    It also has a FAQ which details how to read and shred XML into tables as well as other common XML based questions...
    XML DB FAQ

  • How to write a CLOB to file using UTF-8

    I'm new to java and I have the following problem.
    I need to write a CLOB to file using the UTF-8 characterset (I'm generating an xml file). My database characterset is WE8ISO8859P15.
    I've tried the code below but the resulting output fails validation in an xml editor due to an 'invalid character' error :
    create or replace
    and compile
    java source named "ClobUtil"
    as
    import java.io.*;
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    public class ClobUtil {
    public static void save(CLOB clob, String filename) throws Exception
    Connection conn = DriverManager.getConnection("jdbc:oracle:kprb:");
    conn.setAutoCommit(false);
    InputStream is = clob.getCharacterStream();
    FileOutputStream os = new FileOutputStream(filename);
    int size = clob.getChunkSize();
    byte buffer[] = new byte[size];
    int length;
    while ((length = is.read(buffer, 0, size)) != -1) {
    os.write(buffer, 0, length);
    is.close();
    os.close();
    conn.close();
    I see that the getCharacterStream() method returns a Unicode character stream but how do I output this to file ??
    Thanks in advance

    File file = new File( "myfile.utf8" );
    FileOutputStream fos = new FileOutputStream( file );
    OutputStreamWriter osw = new
    OutputStreamWriter( fos, "UTF8" );
    Writer w = new BufferedWriter( osw );
    PrintWriter out = new PrintWriter( w );
    Or whatever you need. Note that this merely allows you to specify the encoding to be used in the output file, it does convert the encoding for you. I think in your case this will work since you already know the output stream will not contain the full range of UTF8 characters anyway.

Maybe you are looking for

  • Is there any function to automatically adjust the voice volume in the multitrack

    I'm trying to mix voice sounds and music files into one track. Sounds easy! But almost every music has its loud parts(for example the climax) and quiet parts. Therefore when i listen to the voice and the music at the same time, the voice files are so

  • Playlists in new format

    I'm still learning how to use the new iTunes format. Today I purchased an album and added it to theapprpriate playlist. That list was alreadyon my iPod Touch, so I want to replace it with the updated version. The problem is that I casn't figure out h

  • Get error 403 when trying to download from MAS

    Hi! When I'm trying to download any program from MAS, I get 403 error. The same with update. App Store for iOS works fine. I tried: - reboot - reinstall MAS - different account - hide with tor - change password - change language Using 10.6.6 with all

  • Can anyone help Me? After system Restore

    I have a H215 Desktop running Win7 and never got any CD discs with this PC I had to do a System restore useing  Lenovo Rescue (hiddin partion) and of course now MS Office wants my license Key for my office suite Is there anyway to find this key? or c

  • ThinkVantage Toolbox won't run on X61s, Win7 x64

    I booted my X61s today after not running it for 2-3 months.  It gave me an error right after the Toolbox splash screen:  "ThinkVantage Toolbox has stopped working."  It keeps popping up every 5 minutes or so.  I've updated my ThinkVantage technology