Writing a universal file sizeof() method.

Hi,
I am writing an application that needs to compute the exact size of a file. I need for this function to work in Windows and UNIX.
One of my issues is that the length() method provided by the File class does not return the exact size of all files.
The essence of my problem is that I cannot properly compute the size of a directory or symbolic links in UNIX.
File.class() returns 0 for the size of directories regardless of OS. This appears to be correct on Windows (right-click -> properties on an empty directory in Windows). However this seems to be incorrect according to Linux.
When compared to the output of ls, the File.length() method will not return the proper length of directories (whether on a FAT or reiserfs file system) and symbolic links in UNIX. When the windows partition is mounted in Linux, the size of the directories on the windows partition are reported as being 4096 by file system utilities ls and du.
This contrasts the value of zero reported by the Microsoft 98 Windows Explorer. Moreover, the size of directories on reiserfs file systems seem to be unpredictable. (Whereas the size of a symbolic link is the length of the filename it is pointing to.)
Detailed examples of my problem can be found at the following thread: http://forum.java.sun.com/thread.jspa?threadID=574755
How can I compute a function that will be able to compute the size of any file under any operating system?
I would like to avoid his path:
    1. Determine if the class is being run in Windows or UNIX
    2. If running in UNIX,
           a. If a directory of symbolic link: execute : du -sb [file] | awk '{print $1}'
              or ls -al [file ] | awk ' { print  $5 }'
           b. Otherwise: File.length()
    3. If running Windows, simply class File.length() (?)By taking this route I need to perform an if() statement every time the size of any file is being computed, and also execute an expensive command for some special cases (which will common).
Thanks in advance for reading the entire article and thinking about potential solutions.

I am writing an application that will take an arbitrary number of directories, and split the data into the appropriately size chunks to be burned onto CDs.
The directories are passed as strings, and I am currently using Java classes to compute the size of the files. The computed size of the files must be accurate, as I am passing the segmented files into mkisofs (to create an image), and then burn that image onto a CD using cdrecord.
If the sizes are not computed properly, too many files may be passed to mkisofs (and the CD will be bad); or that the code is not entirely efficient (or correct).
As a "correct" value to use against validation, I use du on UNIX and the "properties" command on Windows.
My problem arises on UNIX where the File.length() method returns 0. My computed value is always less than the value given by du, since the values of directories are not properly computed because of the length() method.
This also makes the application difficult to debug. Specifially, verifying that all files passed in are actually all there. IE, are small directories missing or are there small files missing?

Similar Messages

  • Expdp with parallel writing in one file at a time on OS

    Hi friends,
    I am facing a strange issue.Despite giving parallel=x parameter the expdp is writing on only one file on OS level at a time,although it is writing into multiple files sequentially (not concurrently)
    While on other servers i see that expdp is able to start writing in multiple files concurrently. Following is the sample log
    of my expdp .
    ++++++++++++++++++++
    Export: Release 10.2.0.3.0 - 64bit Production on Friday, 15 April, 2011 3:06:50
    Copyright (c) 2003, 2005, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    Starting "CNVAPPDBO4"."EXPDP_BL1_DOCUMENT": CNVAPPDBO4/********@EXTTKS1 tables=BL1_DOCUMENT DUMPFILE=DUMP1_S:Expdp_BL1_DOCUMENT_%U.dmp LOGFILE=LOG1_S:Expdp_BL1_DOCUMENT.log CONTENT=DATA_ONLY FILESIZE=5G EXCLUDE=INDEX,STATISTICS,CONSTRAINT,GRANT PARALLEL=6 JOB_NAME=Expdp_BL1_DOCUMENT
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 23.93 GB
    . . exported "CNVAPPDBO4"."BL1_DOCUMENT" 17.87 GB 150951906 rows
    Master table "CNVAPPDBO4"."EXPDP_BL1_DOCUMENT" successfully loaded/unloaded
    Dump file set for CNVAPPDBO4.EXPDP_BL1_DOCUMENT is:
    /tksmig/load2/oracle/postpaidamd/DUMP1_S/Expdp_BL1_DOCUMENT_01.dmp
    /tksmig/load2/oracle/postpaidamd/DUMP1_S/Expdp_BL1_DOCUMENT_02.dmp
    /tksmig/load2/oracle/postpaidamd/DUMP1_S/Expdp_BL1_DOCUMENT_03.dmp
    /tksmig/load2/oracle/postpaidamd/DUMP1_S/Expdp_BL1_DOCUMENT_04.dmp
    Job "CNVAPPDBO4"."EXPDP_BL1_DOCUMENT" successfully completed at 03:23:14
    ++++++++++++++++++++
    uname -aHP-UX ocsmigbrndapp3 B.11.31 U ia64 3522246036 unlimited-user license
    Is it hitting any known bug? Please suggest.
    regds,
    kunwar

    PARALLEL always using with DUMPFILE=filename_*%U*.dmp. Did yoy put the same parameter on target server?
    PARALLEL clause depend on server resources. If the system resources allow, the number of parallel processes should be set to the number of dump files being created.

  • Problem writing object to file

    Hi everyone,
    I am creating an index by processing text files. No of files are 15000 and index is a B+ Tree. when all files processed and i tried to write it to the file it gives me these errors.
    15000 files processed.
    writing to disk...
    Exception in thread "main" java.lang.StackOverflowError
            at sun.misc.SoftCache.processQueue(SoftCache.java:153)
            at sun.misc.SoftCache.get(SoftCache.java:269)
            at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:244)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1029)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:380)
            at java.util.Vector.writeObject(Vector.java:1018)
            at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:380)
            at java.util.Vector.writeObject(Vector.java:1018)
            at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
    ..........can anyone point out the mistake im doing?
    thanks

    the B+ Tree is balanced and is perfectly working without writing to the file. and i am using default writeObject() method of ObjectOutputStream.
      try {
                                FileOutputStream   f_out   = new   FileOutputStream ("tree.idx");
                                ObjectOutputStream obj_out = new   ObjectOutputStream (new BufferedOutputStream (f_out));   
         for (int x = 0, l = files.length; x < l; x++) {
              ProcessTree(files[x].toString());
                    System.out.println("Writing main index to the disk...");
                    obj_out.writeObject (tree); 
                    obj_out.flush();
                    obj_out.close();
                    } catch (Exception e)
          System.out.println (e.toString ());
          System.out.println("Error Writing to Disk!");
        }

  • How to insert new line char while writing bytes into file

    Hello Sir,
    Is it possible to insert the new line character in set of String variables and stored them into bytearray ,then finally write into File?
    This is the sample code which i tried:
                 File f = new File(messagesDir,"msg" + msgnum + ".txt");
                 FileOutputStream fout = new FileOutputStream(f);
                    String fromString = "From:    "+msg.getFrom()+"\n";
                    String toString = "To:     "+msg.getTo()+"\n";
                    String dateString = "Sent:    "+msg.getDate()+"\n";
                      String msgString =msg.getBody()+"\n";
                    String finalString=fromString+toString+dateString+msgString;
                    byte[] msgBytes = finalString.getBytes();
                    fout.write(msgBytes);
                 fout.close();in the above code , i tried to add the new line as "\n" in end of each string. but when i look into the generated files msg1.txt , it contains some junk char [] .
    please provide me the help
    regards
    venki

    but it has still shown the the junk char, its not able
    to create the new line in the created file i am afraid
    how am i going to get the solution?:(Do not be afraid dear sir. You are obviously using a windows operating system or a mac operating system. On windows a newline is "\r\n" not '\n', and on a mac a newline is '\r', not '\n'. If you make that correction, dear sir, your program will work.
    However, there is a better way. First, you probably want to buffer your output if you are going to write more than one time to the file, which will make writing to the file more efficient. In addition, when you buffer your output, you can use the newLine() method of the BufferedWriter object to insert a newline. The newline will be appropriate for the operating system that the program is running on. Here is an example:
    File f = new File("C:/TestData/atest.txt");
    BufferedWriter out = new BufferedWriter(new FileWriter(f) );
    String fromString = "From: Jane";
    out.write(fromString);
    //Not written to the file until enough data accumulates.
    //The data is stored in a buffer until then.
    out.newLine();
    String toString = "To: Dick";
    out.write(toString);
    out.newLine();
    String dateString = "Sent: October 27, 2006";
    out.write(dateString);
    out.newLine();
    out.close(); 
    //Causes any unwritten data to be flushed from
    //the buffer and written to the file.

  • Writing output to file does not work

    Hello All,
    I have a problem with writing to a file created on the command prompt:
    1) my base class is called TestRandom2
    2) I have a method called run which runs the print method
    3) I passed a reference of the run method into the main below, I don't know if I'm doing it correctly but the error message I'm getting "cannot resolve variable symbol : variable String
    location: class TestRandom2 return String;"
    4)When I declare the method run as void it's also giving an error.
    5)I would to fix this proble to write my output to a .xls file. Can someone help me as soon as possible please!!!!
    public static void main(String[] args) throws Exception {
         TestRandom2 testrandom = new TestRandom2();
              byte b[] = new String(testrandom.run()).getBytes();
              OutputStream o = new FileOutputStream(args[0]);
              o.write(b);
              o.close();
         }

    this is my entire file, I want to be able to call the run method in main and have the file out put to an xls file can some one help me please
    Code ------
    import java.io.*;
    public class TestRandom2{
         Deck deck = new Deck();
         public TestRandom2(){
              deck.populate();
         public void run(String file){
                   if(file.equals("") || file==null)
                   throws IOException {
                   FileOutputStream output=new FileOutputStream(file);
                   for(int i=0; i<5; i++){
                   deck.shuffle();
                   deck.print();
                   output.close;
         class Deck{
              public void populate(){
                   System.out.println("populating deck!");
                   cards=new Integer[52];
                   for(int i=0;i<52;i++){
                        cards= new Integer(i+1);
         public void shuffle(){
              System.out.println("Shuffling deck!");
              rnd.setSeed(randomseed.getSeed());
              java.util.List list = java.util.Arrays.asList(cards);
              java.util.Collections.shuffle(list,rnd);
              cards = (Integer[])list.toArray(new Integer[0]);
         public void print(){
              System.out.println("populating deck!");
              for(int i=0;i<cards.length;i++){
                   System.out.print("P:"+(i+1));
                   System.out.print("C:"+cards[i].intValue());
              Integer[] cards = null;
              RandomSeed randomseed = new RandomSeed();
              java.util.Random rnd = new java.util.Random();
              class RandomSeed {
         private long[] seeds = new long[] {
              9876, 54321,
              1299961164, 253987020,
              669708517, 2079157264,
              190904760, 417696270,
              1289741558, 1376336092,
              1803730167, 324952955,
              489854550, 582847132,
              1348037628, 1661577989,     
              350557787, 1155446919,          
              591502945, 634133404,
              1901084678, 862916278,     
              1988640932, 1785523494,     
              1873836227, 508007031,          
              1146416592, 967585720,
              1837193353, 1522927634,
              38219936, 921609208,
              349152748, 112892610,          
              744459040, 1735807920,
              1983990104, 728277902,
              309164507, 2126677523,
              362993787, 1897782044,
              556776976, 462072869,
              1584900822, 2019394912,
              1249892722, 791083656,          
              1686600998, 1983731097,
              1127381380, 198976625,
              1999420861, 1810452455,
              1972906041, 664182577,          
              84636481, 1291886301,
              1186362995, 954388413,
              2141621785, 61738584,
              1969581251, 1557880415,          
              1150606439, 136325185,
              95187861, 1592224108,
              940517655, 1629971798,
              215350428, 922659102,     
              786161212, 1121345074,
              1450830056, 1922787776,
              1696578057, 2025150487,
              1803414346, 1851324780,          
              1017898585, 1452594263,
              1184497978, 82122239,
              633338765, 1829684974,
              430889421, 230039326,          
              492544653, 76320266,
              389386975, 1314148944,
              1720322786, 709120323,
              1868768216, 1992898523,          
              443210610, 811117710,
              1191938868, 1548484733,
              616890172, 159787986,
              935835339, 1231440405,     
              1058009367, 1527613300,
              1463148129, 1970575097,
              1795336935, 434768675,
              274019517, 605098487,          
              483689317, 217146977,
              2070804364, 340596558,
              930226308, 1602100969,
              989324440, 801809442,          
              410606853, 1893139948,
              1583588576, 1219225407,
              2102034391, 1394921405,
              2005037790, 2031006861,          
              1244218766, 923231061,
              49312790, 775496649,
              721012176, 321339902,
              1719909107, 1865748178,          
              1156177430, 1257110891,
              307561322, 1918244397,
              906041433, 360476981,
              1591375755, 268492659,          
              461522398, 227343256,
              2145930725, 2020665454,
              1938419274, 1331283701,     
              174405412, 524140103,          
              494343653, 18063908,
              1025534808, 181709577,
              2048959776, 1913665637,
              950636517, 794796256,          
              1828843197, 1335757744,
              211109723, 983900607,
              825474095, 1046009991,
              374915657, 381856628,          
              1241296328, 698149463,
              1260624655, 1024538273,
              900676210, 1628865823,
              697951025, 500570753,          
              1007920268, 1708398558,
              264596520, 624727803,
              1977924811, 674673241,
              1440257718, 271184151,          
              1928778847, 993535203,
              1307807366, 1801502463,
              1498732610, 300876954,
              1617712402, 1574250679,          
              1261800762, 1556667280,
              949929273, 560721070,
              1766170474, 1953522912,
              1849939248, 19435166,          
              887262858, 1219627824,
              483086133, 603728993,
              1330541052, 1582596025,
              1850591475, 723593133,          
              1431775678, 1558439000,
              922493739, 1356554404,
              1058517206, 948567762,
              709067283, 1350890215,          
              1044787723, 2144304941,
              999707003, 513837520,
              2140038663, 1850568788,
              1803100150, 127574047,          
              867445693, 1149173981,
              408583729, 914837991,
              1166715497, 602315845,
              430738528, 1743308384,          
              1388022681, 1760110496,
              1664028066, 654300326,
              1767741172, 1338181197,
              1625723550, 1742482745,          
              464486085, 1507852127,
              754082421, 1187454014,
              1315342834, 425995190,
              960416608, 2004255418,          
              1262630671, 671761697,
              59809238, 103525918,
              1205644919, 2107823293,
              1615183160, 1152411412,          
              1024474681, 2118672937,
              1703877649, 1235091369,
              1821417852, 1098463802,
              1738806466, 1529062843,          
              620780646, 1654833544,
              1070174101, 795158254,
              658537995, 1693620426,
              2055317555, 508053916,          
              1647371686, 1282395762,
              29067379, 409683067,
              1763495989, 1917939635,
              1602690753, 810926582,          
              885787576, 513818500,
              1853512561, 1195205756,
              1798585498, 1970460256,
              1819261032, 1306536501,          
              1133245275, 37901,
              689459799, 1334389069,
              1730609912, 1854586207,
              1556832175, 1228729041,
              251375753, 683687209,
              2083946182, 1763106152,
              2142981854, 1365385561,
              763711891, 1735754548,
              1581256466, 173689858,
              2121337132, 1247108250,
              1004003636, 891894307,
              569816524, 358675254,
              626626425, 116062841,
              632086003, 861268491,
              1008211580, 779404957,
              1134217766, 1766838261,
              1423829292, 1706666192,
              942037869, 1549358884,
              1959429535, 480779114,
              778311037, 1940360875,
              1531372185, 2009078158,
              241935492, 1050047003,
              272453504, 1870883868,
              390441332, 1057903098,
              1230238834, 1548117688,
              1242956379, 1217296445,
              515648357, 1675011378,
              364477932, 355212934,
              2096008713, 1570161804,
              1409752526, 214033983,
              1288158292, 1760636178,
              407562666, 1265144848,
              1071056491, 1582316946,
              1014143949, 911406955,
              203080461, 809380052,
              125647866, 1705464126,
              2015685843, 599230667,
              1425476020, 668203729,
              1673735652, 567931803,
              1714199325, 181737617,
              1389137652, 678147926,
              288547803, 435433694,
              200159281, 654399753,
              1580828223, 1298308945,
              1832286107, 169991953,
              182557704, 1046541065,
              1688025575, 1248944426,
              1508287706, 1220577001,
              36721212, 1377275347,
              1968679856, 1675229747,
              279109231, 1835333261,
              1358617667, 1416978076,
              740626186, 2103913602,
              1882655908, 251341858,
              648016670, 1459615287,
              780255321, 154906988,
              857296483, 203375965,
              1631676846, 681204578,
              1906971307, 1623728832,
              1541899600, 1168449797,
              1267051693, 1020078717,
              1998673940, 1298394942,
              1914117058, 1381290704,
              426068513, 1381618498,
              139365577, 1598767734,
              2129910384, 952266588,
              661788054, 19661356,
              1104640222, 240506063,
              356133630, 1676634527,
              242242374, 1863206182,
              957935844, 1490681416 };
         public void longToLong(){
              for (int i=0;i<(seeds.length);i++){
                   seedsArray[i] = new java.lang.Long(seeds[i]);
         public boolean checkForSeed(long seed){
              for(int i=0;i<lastSeed.length;i++){
                   if (seed == lastSeed[i])
                        return true;
              addSeed(seed);
              return false;
         public void addSeed(long seed){     
              if (!(currentseedpos < maxSeeds))
                   currentseedpos = 0;
              lastSeed[currentseedpos] = seed;
         public boolean checkForValue(int value){
              for(int i=0;i<lastValue.length;i++){
                   if (value == lastValue[i])
                        return true;
                   addValue(value);
                   return false;
         public void addValue(int value){
              if (!(currentvaluepos < maxValues))
                   currentvaluepos = 0;
              lastValue[currentvaluepos] = value;
         public RandomSeed(){
              lastValue = new int[maxValues];
              lastSeed = new long[maxSeeds];
              longToLong();
              shuffle();
         public RandomSeed(int v){
              maxValues = v;
              lastValue = new int[maxValues];
              lastSeed = new long[maxSeeds];
              longToLong();
              shuffle();
         public RandomSeed(int v, int s){
              maxValues = v;
              maxSeeds = s;
              lastValue = new int[maxValues];
              lastSeed = new long[maxSeeds];
              longToLong();
              shuffle();
         public void shuffle(){
              random.setSeed(seeds[random.nextInt(seeds.length-1)]);
              java.util.List list = java.util.Arrays.asList(seedsArray);
              java.util.Collections.shuffle(list,random);
         public long getSeed(){
              shuffle();
              random.setSeed(seeds[random.nextInt(seeds.length-1)]);
              long seed=seedsArray[random.nextInt(seeds.length-1)].longValue();
              while (checkForSeed(seed))seed=seedsArray[random.nextInt(seeds.length-1)].longValue();
              return seed;
         public int nextInt(int max){
              shuffle();
              random.setSeed(seeds[random.nextInt(seeds.length-1)]);
              long seed = seedsArray[random.nextInt(seeds.length-1)].longValue();
              while (checkForSeed(seed))
                   seed = seedsArray[random.nextInt(seeds.length-1)].longValue();
                   random.setSeed(seed);
                   int seedone = random.nextInt(max)+1;
                   if (checkForValue(seedone))
                   seedone = random.nextInt(max)+1;
                   return (seedone);
         public int nextInt(){
              return nextInt(MAXINT);
         }     private int currentseedpos = 0;
         private int currentvaluepos = 0;
         public int lastValue[] = new int[0];
         public long lastSeed[] = new long[0];
         public final int MAXINT = 9999;
         public int maxSeeds = 400;
         public int maxValues = 5;
         private java.lang.Long[] seedsArray = new java.lang.Long[seeds.length];
         private java.util.Random random = new java.util.Random();
         public static void main(String[] args) throws Exception {
         TestRandom2 testrandom = new TestRandom2();
              testrandom.run();
    ----Code
    Thanks for all the response I've been getting please continue to help

  • File.WriteContents writing to hidden files?

    I have noticed that File.WriteContents writes to premade files or makes files but i was wondering if there was something that would allow writing to hidden files, is this possible?

    First NOTE what JJ said.
    Supposed a testfile "C:\Program Files\Microsoft\Small Basic\Projects\TestFile.txt"  (here with space(s) in path)
    and a original set attribute of +H for the testfile, you could use:
    '------------- SNIP -------------
    qu = Text.GetCharacter(34)
    txtFile = "C:\Program Files\Microsoft\Small Basic\Projects\TestFile.txt"
    txt = "My Text to write"
    cmdLine = "-H " +qu+ txtFile +qu   '' clears the 'hidden / H' attribute only
    cmdLine = qu+ cmdLine +qu
    LDProcess.Start("attrib.exe", cmdLine)
    res = File.WriteContents(txtFile, txt)
    TextWindow.WriteLine(res)
    ' -------- SNAP -----------
    Depending on the set attributes (can be checked with
    attr = LDShell.GetDetail(txtFile, 6)  '' or
    'attr2 = LDShell.GetDetail(txtFile, "Attributes")  ' on an
    engl. System
    you will have to ev. temporary set back others as well. eg. 'attrib.exe -H -S -R txtFile',
    remember the original attribute(s) and, after writing to txtFile,
    set back again (eg. attrib.exe +H +S +R txtFile) to the original attributes.
    PS: If you are on SB 1.0 there is Data extension's 'FilePlus' object, which supports some methods for attributes (like .ContainsAttiribute, AddAttiribute, RemoveAttiribute). Perhaps further ('old') extensions that support attributes (like 'Fremy' etx ??
    etc), but unfortunaltely the don't work any more for SB 1.1.
    At any rate: You should KNOW what you are doing !!

  • Please help with "Error writing the project file. The specified module could not be found." error.

    I am a student.  I've been trying to install and use Visual Studio 2013 Professional for three weeks now and I cannot get it to work.  I am now two weeks behind in my Visual Basic class.  I've installed, uninstalled, ran the repair option... 
    I've tried everything I know how to do.  I just spent 45 minutes on the phone with Microsoft, was transferred four times and finally told I will have to use the forums to find an answer.  I'm almost completely out of patience with this.
    I got the software through the Dream Spark program as a student.  I installed it with the web installer and it appeared to install fine.  When I try to create a new project, I get the error:  "Error writing the project file.  The
    specified module could not be found."
    When I exit the application, I also get:  "The automatically saved settings file 'c:\users\user\documents\visual studio 2013\Settings\CurrentSettings-2015-02-02.vssettings' is not available for write.  You can change this file on the 'Import
    and Export Settings' Tools Options page."
    Please tell me you can help.

    Hi,
    could you please try the points mentioned here:
    http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/0376db8f-4761-4ae5-9af2-98c53216318a#VS_IDE_unexpected_problems to eliminate the possible cause of your issue?
    Please update the result in the forum after you try the method above!
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to sync writing to a file?

    Hi all,
    I'm implementing a simple line logger for my web applications.
    Basically, I have some class with a "write" method, that appends a line of text into a certain file.
    All of my web apps log into the same file (by design).
    How do I make sure writing to the file is synchronized?
    The web apps cannot share logger objects between them (not even singletons, correct?) so using the 'synchronized' qualifier for the 'write' method won't work because each web app has its own instance of the logger object.
    Also, FileLock won't work since all web apps "live" inside the same JVM (accoding to javadoc, FileLock is not suitable for syncing file-writes by different threads within the same JVM).
    I've looked up the forum for answers to these questions, but non of the threads on this topic provided any leads...
    Any ideas?

    hii...
    can sum1 plz tell me how to replace bytes in a file?
    i've used randomaccess to open the file....read is
    contents and write back to it at the desired
    locations using seek()...however at some position if
    i wish to read the data and replace it with new data
    at exactly the same location...how can i do it??
    bye.i had already mentioned my problem....actually i want to read a record from a file and then update it at the same location in the file...so i need to replace it(or delete the record and re-write the new info).

  • Error in writing to export file

    Hi,
    I am getting the below error on running export:-
    EXP-00002: error in writing to export file
    The query is as given below:-
    exp cam3_mpcb2/cam3_mpcb2@ORA10G file='c:\MPCB_cam_20120113.dmp' log='c:\MPCB_20120113.log'
    CAn i overcome this error by adding "ignore" at the end of the query or how can i modify the above query ?

    Are there any other error messages that accompany the one you posted?
    EXP-00002: error in writing to export file
    Cause: Export could not write to the export file, probably because of a device error. This message is usually followed by a device message from the operating system.
    Action: Take appropriate action to restore the device. Do you have permissions to write to this location?

  • Error while writing to a file

    Hi,
    I am getting an error while writing to a file.Here is the sample code in which I am getting error.The STDERR is getting printed to console but the same is not getting written to a file.
    package Sample;
    import java.util.*;
    import java.io.*;
    public class MediocreExecJavac
    public static void main(String args[])
    try
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("perl ic_start");
    InputStream stderr = proc.getErrorStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    FileWriter fw=new FileWriter("result.txt");
    String line = null;
    System.out.println("<ERROR>");
    while ( (line = br.readLine()) != null)
    System.out.println(line);
    fw.write(line);
    System.out.println("</ERROR>");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    fw.close();
    } catch (Throwable t)
    t.printStackTrace();
    }Below is the output -
    <ERROR>
    Can't open perl script "ic_start": No such file or directory
    java.lang.NullPointerException
    at java.io.Writer.write(Unknown Source)
    at Sample.MediocreExecJavac.main(MediocreExecJavac.java:21)
    Please tell where the program is going wrong.

    i think it is just the path of file that u r missing

  • Writing out to file - and it seems to overwrite data

    I have written a program that reads in a file and then writes out XML. It works fine with small files but with files that are 1,310 kb it, seems to overwrite itself and i end up with a file that is missing its begining and middle pieces. I suspect that I am blowing out some buffer and a java component is reseting itself and overwriting the file, but i am scratching my head. Code below, please excuse the unformatted nature of the code.
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.*;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class dl414image {
    public static String all = "";
    public static String fname = "";
    public static String lname = "";
    public static String mname = "";
    public static boolean aflag = false;
    public static boolean endofrec = false;
    public static boolean bflag = false;
    public static boolean cflag = false;
    public static boolean dflag = false;
    public static String xmldl;
    public static String xmlreq;
    public static String xml_issue_date;
    public static String xml_first_name;
    public static String xml_middle_name;
    public static String xml_last_name;
    public static String xml_dmvinfo;
    public static String xmlbday;
    public static String xmlsex;
    public static String xmlheight;
    public static String xmlweight;
    public static String xmleyecolor;
    public static String xmlhaircolor;
    public static String xml_licenseclass;
    public static String xml_licenseclassname;
    public static String xml_licenseissuedate;
    public static String xml_licenseexpiresdate;
    public static String dlstart = "<dlnumber>";
    public static String dlend = "</dlnumber>";
    public static String xmlreqstart = "<requestor_code>";
    public static String xmlreqend = "</requestor_code>";     
    public static String issue_date_start = "<issue_date>";
    public static String xml_issue_date_end = "</issue_date>";
    public static int count = 0;
    public static List<String> xml_abstractline = new ArrayList<String>();
    public static List<String> xml_cline = new ArrayList<String>();
    public static List<String> xml_dline = new ArrayList<String>();
    public static List<String> xml_acontinuedline = new ArrayList<String>();
    public static String dlold; // holds the previous DL number
    public static final String HEX_EXP = "[\\xFF]";
    public static final String CDATASTART = " <![CDATA[";
    public static final String CDATAEND = "]]>";
    public static String xmlfobates = "";
    public static String xmltypeappdate = "";
    public static String xml_licenseext;
    public static String xml_licenserestrict;
    public static String xml_licensedup;
    public static String xml_licenseheld;
    public static String xml_licenseseq;
    public static List<String> xml_abstract_item = new ArrayList<String>();
    public static List<String> xml_abstract_violationdate = new ArrayList<String>();
    public static List<String> xml_abstract_convictdate = new ArrayList<String>();
    public static List<String> xml_abstract_sectviolated = new ArrayList<String>();
    public static List<String> xml_abstract_statute = new ArrayList<String>();
    public static List<String> xml_abstract_file_number = new ArrayList<String>();
    public static List<String> xml_abstract_location_or_arn = new ArrayList<String>();
    public static List<String> xml_abstract_vehicle_license = new ArrayList<String>();
    public static final String ABST = "ABST";
    public static List<String> xml_reqNameAddress = new ArrayList<String>();
         /**<p>
         * This code reads in a file line by line
         * with BufferedReader and processes each
         * line.
         * @author Toren Valone
         public static void main(String[] args) {
              read("U:\\dlbig.txt"); //read this file
    //     convenience method to encapsulate
    //     the work of reading data.
         public static void read(String fileName) {
              xmlwriter("<?xml version=\"1.0\"?>");
              xmlwriter("<?xml-stylesheet type=\"text/xsl\" href=\"dl414.xsl\"?>" );
              xmlwriter("<dl_records>"); //write base element start tag
         try {
         BufferedReader in = new BufferedReader(
         new FileReader(fileName));
         String line;
         while ((line = in.readLine()) != null) {
              String cleanline = stripNonValidXMLCharacters(line);
         //our own method to do something
         handle(cleanline);
         //count each line
         count++;
         in.close();
         //show total at the end of file
         log("Lines read: " + count);
         } catch (IOException e) {
         log(e.getMessage());
         dlxmlwriter(); //final write for process
              xmlwriter("</dl_records>"); //write base element end tag
    //     does the work on every line as it is
    //     read in by our read method
         private static void handle(String line){
              if(line.length()> 0) {
              char fbyte = line.charAt(0);
              if(fbyte == 'A') {
              //just grab the very first dl
              if(count == 0) {
              dlold = line.substring(3,11);
              aflag = true;
              cflag = false;
              dflag = false;
              if(dlold.equalsIgnoreCase(line.substring(3,11))) {
              } else {
                   dlxmlwriter();
              //create Drivers License XML
                   xmldl = dlstart + line.substring(3,11) + dlend;
                   //grab f.o bates no only if its there otherwise write empty xml
              xmlfobates = "<fobates>" + line.substring(12,19) + "</fobates>";
              //grab type app and date
              xmltypeappdate = "<typeappdate>" + line.substring(20,28) + "</typeappdate>";
                   //Create Requestor code XML
              xmlreq = xmlreqstart + line.substring(51,56) + xmlreqend;
              //Create issue date XML
              xml_issue_date = issue_date_start + line.substring(57,63) + xml_issue_date_end;
              // clear name values, for now too stupid to figure out
              fname = "";
              mname = "";
              lname = "";     
              //Pulls the whole name string and sends it to namer function
              //to break up
              String name = line.substring(72);
              namer(name);
              //Create a string array and call get_Names which returns a
              //string array
              xml_first_name = "<first_name>" + fname + "</first_name>";
              xml_middle_name = "<middle_name>" + mname + "</middle_name>";
              xml_last_name = "<last_name>" + lname + "</last_name>";
                   //store Dl for comparison
                   store_old_dl(line);
              //Accent a and a length of 59 or 102 contains
              //the dmv info line
              if((fbyte == '?')& (line.length() == 59)){
                   String cleandmvinfo = regexReplacer(line.substring(38,58),"//","");
                   xml_dmvinfo = "<dmv_info_line>" + cleandmvinfo + "</dmv_info_line>";
              //Line length of 33 Birthdate, Sex, Height, Weight
              //Eye color hair color
              if ((line.length() == 33 ) & (aflag == true)) {
                   xmlbday = "<birth_date>" + line.substring(3, 9) + "</birth_date>";
                   xmlsex = "<sex>" + line.substring(11,12) + "</sex>";
                   xmlheight = "<height>" + line.substring(14,17) + "</height>";
                   xmlweight = "<weight>" + line.substring(18,21) + "</weight>";
                   xmleyecolor = "<eye_color>" + line.substring(22,27) + "</eye_color>";
                   xmlhaircolor = "<hair_color>" + line.substring(28,line.length()) + "</hair_color>";
    //Line length of 35 Birthdate, Sex, Height, Weight
              //Eye color hair color
              if ((line.length() == 31     ) & (aflag == true)) {
                   xmlbday = "<birth_date>" + line.substring(3, 9) + "</birth_date>";
                   xmlsex = "<sex>" + line.substring(11,12) + "</sex>";
                   xmlheight = "<height>" + line.substring(14,17) + "</height>";
                   xmlweight = "<weight>" + line.substring(18,21) + "</weight>";
                   xmleyecolor = "<eye_color>" + line.substring(22,27) + "</eye_color>";
                   xmlhaircolor = "<hair_color>" + line.substring(28,31) + "</hair_color>";
    // Line length of 56 Birthdate, Sex, Height, Weight
              //Eye color hair color for Annual reports
              if ((line.length() == 56     ) & (aflag == true)) {
                   xmlbday = "<birth_date>" + line.substring(3, 9) + "</birth_date>";
                   xmlsex = "<sex>" + line.substring(11,12) + "</sex>";
                   xmlheight = "<height>" + line.substring(14,17) + "</height>";
                   xmlweight = "<weight>" + line.substring(18,21) + "</weight>";
                   xmleyecolor = "<eye_color>" + line.substring(22,27) + "</eye_color>";
                   xmlhaircolor = "<hair_color>" + line.substring(28,31) + "</hair_color>";
              //If the line has an accent a and a length of 6
              if ((fbyte == '?')& (line.length() == 6)) {
              xml_licenseclass = "<license_class>" + line.substring(5,6) + "</license_class>";
              if ((fbyte == '?')& (line.length() == 8)) {
                   String cleanlc = regexReplacer(line.substring(4,8),"&","&");
                   xml_licenseclass = "<license_class>" + cleanlc + "</license_class>";
              if((line.length() == 61) & aflag==true) {
                   xml_licenseclassname = "<license_class_name>" + line.substring(3,9) + "</license_class_name>";
                   xml_licenseissuedate = "<license_issue_date>" + line.substring(9,16) + "</license_issue_date>";
                   xml_licenseexpiresdate = "<license_expires_date>" + line.substring(16,23) + "</license_expires_date>";
                   xml_licenseext = "<license_ext>" + line.substring(23,26) + "</license_ext>";
                   xml_licenserestrict = "<license_restrict>" + line.substring(26,37) + "</license_restrict>";          
                   xml_licensedup = "<license_dup>" + line.substring(38,43) + "</license_dup>";
                   xml_licenseheld = "<license_held>" + line.substring(44,44) + "</license_held>";
                   xml_licenseseq = "<license_seq>" + line.substring(57,61) + "</license_seq>";
              if(fbyte == 'B') {
                   bflag = true;
                   aflag = false; //ok got the a now turn switch off
                   String cleanabstract = regexReplacer(line.substring(1,line.length()),HEX_EXP,"");
                   cleanabstract = regexReplacer(cleanabstract,"&","&");
                   cleanabstract = regexReplacer(cleanabstract,"&","&apos;");
              if(cleanabstract.substring(3, 7).equalsIgnoreCase("ABST")){
                   if(cleanabstract.length() == 107) {               
                        xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,8) + "</abstract_item>");
                   xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                   xml_abstract_convictdate.add("<abs_convict_date>" + cleanabstract.substring(15,21) + "</abs_convict_date>");
                   xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                   xml_abstract_statute.add("<abs_statute>" + cleanabstract.substring(42,46) + "</abs_statute>");
                   xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                   xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,99) + "</abs_location_or_arn>");
                   xml_abstract_vehicle_license.add("<abs_vehicle_license>" + cleanabstract.substring(100,107) + "</abs_vehicle_license>");               
                   if(cleanabstract.length() > 80 & cleanabstract.length() < 107) {               
                        xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,8) + "</abstract_item>");
                   xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                   xml_abstract_convictdate.add("<abs_convict_date>" + cleanabstract.substring(15,21) + "</abs_convict_date>");
                   xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                   xml_abstract_statute.add("<abs_statute>" + cleanabstract.substring(42,51) + "</abs_statute>");
                   xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                   xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,cleanabstract.length()) + "</abs_location_or_arn>");
                   if(cleanabstract.length() < 80) {
                   System.out.println("****Change your assumtions about length*********");     
                        xml_abstractline.add("<abstract>" + cleanabstract + "</abstract>");
              if(cleanabstract.substring(3, 6).equalsIgnoreCase("ACC")){
                   if(cleanabstract.length() < 107) {
                        System.out.println("Acc looks like!!!" + cleanabstract);
                        System.out.println("Acc length=" + cleanabstract.length());
                   if(cleanabstract.length() > 102) {               
                             xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,6) + "</abstract_item>");
                        xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                        xml_abstract_convictdate.add("<abs_convict_date>" + " " + "</abs_convict_date>");
                        xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                        xml_abstract_statute.add("<abs_statute>" + " " + "</abs_statute>");
                        xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                        xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,99) + "</abs_location_or_arn>");
                        xml_abstract_vehicle_license.add("<abs_vehicle_license>" + cleanabstract.substring(100,cleanabstract.length()) + "</abs_vehicle_license>");               
                   if((cleanabstract.length() > 77 ) & cleanabstract.length() < 102) {               
                             xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,6) + "</abstract_item>");
                        xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                        xml_abstract_convictdate.add("<abs_convict_date>" + " " + "</abs_convict_date>");
                        xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                        xml_abstract_statute.add("<abs_statute>" + " " + "</abs_statute>");
                        xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,cleanabstract.length()) + "</abs_file_number>");
                        xml_abstract_location_or_arn.add("<abs_location_or_arn>" + "</abs_location_or_arn>");
                        xml_abstract_vehicle_license.add("<abs_vehicle_license>" + "</abs_vehicle_license>");               
              if((fbyte == ' ') & (bflag == true)) {
                   String cleanabstract = regexReplacer(line.substring(1,line.length()),HEX_EXP,".");
                   cleanabstract = regexReplacer(cleanabstract,"&","&");
                   cleanabstract = regexReplacer(cleanabstract,"'","&apos;");
                   if(cleanabstract.substring(3, 7).equalsIgnoreCase("ABST")){
                             if(cleanabstract.length() == 107) {               
                                  xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,8) + "</abstract_item>");
                             xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                             xml_abstract_convictdate.add("<abs_convict_date>" + cleanabstract.substring(15,21) + "</abs_convict_date>");
                             xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                             xml_abstract_statute.add("<abs_statute>" + cleanabstract.substring(42,51) + "</abs_statute>");
                             xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                             xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,99) + "</abs_location_or_arn>");
                             xml_abstract_vehicle_license.add("<abs_vehicle_license>" + cleanabstract.substring(100,107) + "</abs_vehicle_license>");               
                             if(cleanabstract.length() > 93 & cleanabstract.length() < 107) {               
                                  xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,8) + "</abstract_item>");
                             xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                             xml_abstract_convictdate.add("<abs_convict_date>" + cleanabstract.substring(15,21) + "</abs_convict_date>");
                             xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                             xml_abstract_statute.add("<abs_statute>" + cleanabstract.substring(42,51) + "</abs_statute>");
                             xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                             xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,cleanabstract.length()) + "</abs_location_or_arn>");
                             xml_abstract_vehicle_license.add("<abs_vehicle_license>" + "</abs_vehicle_license>");               
                   if(cleanabstract.substring(3, 6).equalsIgnoreCase("ACC")){
                             if(cleanabstract.length() > 102) {               
                                       xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,6) + "</abstract_item>");
                                  xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                                  xml_abstract_convictdate.add("<abs_convict_date>" + " " + "</abs_convict_date>");
                                  xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                                  xml_abstract_statute.add("<abs_statute>" + " " + "</abs_statute>");
                                  xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,79) + "</abs_file_number>");
                                  xml_abstract_location_or_arn.add("<abs_location_or_arn>" + cleanabstract.substring(79,99) + "</abs_location_or_arn>");
                                  xml_abstract_vehicle_license.add("<abs_vehicle_license>" + cleanabstract.substring(100,cleanabstract.length()) + "</abs_vehicle_license>");               
                             if((cleanabstract.length() > 77 ) & cleanabstract.length() < 102) {               
                                       xml_abstract_item.add("<abstract_item>" + cleanabstract.substring(3,6) + "</abstract_item>");
                                  xml_abstract_violationdate.add("<abs_violation_date>" + cleanabstract.substring(8,14) + "</abs_violation_date>");
                                  xml_abstract_convictdate.add("<abs_convict_date>" + " " + "</abs_convict_date>");
                                  xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                                  xml_abstract_statute.add("<abs_statute>" + " " + "</abs_statute>");
                                  xml_abstract_file_number.add("<abs_file_number>" + cleanabstract.substring(67     ,cleanabstract.length()) + "</abs_file_number>");
                                  xml_abstract_location_or_arn.add("<abs_location_or_arn>" + "</abs_location_or_arn>");
                                  xml_abstract_vehicle_license.add("<abs_vehicle_license>" + "</abs_vehicle_license>");               
                   if(cleanabstract.length() == 46) {
                   if(cleanabstract.substring(22, 25).equalsIgnoreCase("CDL") & cleanabstract.length() == 46) {
                   xml_abstract_item.add("<abstract_item>" + "</abstract_item>");
                        xml_abstract_violationdate.add("<abs_violation_date>" + "</abs_violation_date>");
                        xml_abstract_convictdate.add("<abs_convict_date>" + "</abs_convict_date>");
                        xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,43) + "</abs_section_violated>");
                        xml_abstract_statute.add("<abs_statute>" + cleanabstract.substring(42,cleanabstract.length()) + "</abs_statute>");
                        xml_abstract_file_number.add("<abs_file_number>" + "</abs_file_number>");
                        xml_abstract_location_or_arn.add("<abs_location_or_arn>" + "</abs_location_or_arn>");
                        xml_abstract_vehicle_license.add("<abs_vehicle_license>" + "</abs_vehicle_license>");               
                   if(cleanabstract.length()> 39 & cleanabstract.length() < 43     ) {
                   if(cleanabstract.substring(22, 25).equalsIgnoreCase("DMV")) {
                        System.out.println("DMV length=" + cleanabstract.length());
                        xml_abstract_item.add("<abstract_item>" + "</abstract_item>");
                        xml_abstract_violationdate.add("<abs_violation_date>" + "</abs_violation_date>");
                        xml_abstract_convictdate.add("<abs_convict_date>" + "</abs_convict_date>");
                        xml_abstract_sectviolated.add("<abs_section_violated>" + cleanabstract.substring(22,cleanabstract.length()) + "</abs_section_violated>");
                        xml_abstract_statute.add("<abs_statute>" + "</abs_statute>");
                        xml_abstract_file_number.add("<abs_file_number>" + "</abs_file_number>");
                        xml_abstract_location_or_arn.add("<abs_location_or_arn>" + "</abs_location_or_arn>");
                        xml_abstract_vehicle_license.add("<abs_vehicle_license>" + "</abs_vehicle_license>");               
                   xml_abstractline.add("<abstract>" + cleanabstract + "</abstract>");
              if(fbyte == 'C') {
                   //turn b flag off
                   aflag = false;
                   bflag = false;
                   cflag = true;
                   String cleancomment = regexReplacer(line.substring(1,line.length()),HEX_EXP,"");     
                   cleancomment = regexReplacer(cleancomment,"&","&");
                   cleancomment = regexReplacer(cleancomment,"'","&apos;");
                   xml_cline.add("<comment_line>" + cleancomment.substring(1,63) + "</comment_line>");
                   xml_reqNameAddress.add("<requestor_name_or_address>" + cleancomment.substring(63,cleancomment.length()) + "</requestor_name_or_address>");
                   System.out.println("In C code dl=" + xmldl + "aflag=" + aflag +"bflag=" + bflag + "cflag=" + cflag);           
              if((fbyte == ' ') & (cflag == true)){
                   String cleancomment = regexReplacer(line.substring(1,line.length()),HEX_EXP,"");     
                   cleancomment = regexReplacer(cleancomment,"&","&");
                   if(cleancomment.length() > 63) {
              xml_reqNameAddress.add("<requestor_name_or_address>" + cleancomment.substring(63,cleancomment.length()) + "</requestor_name_or_address>");
              xml_cline.add("<comment_line>" + cleancomment.substring(1, 63) + "</comment_line>");
                   } else {
                        xml_cline.add("<comment_line>" + cleancomment.substring(1, cleancomment.length()) + "</comment_line>");
              if(fbyte == 'D') {
                   xml_dline.add("<action>" + line.substring(1, line.length()) + "</action>");
                   dflag = true;
                   cflag = false;
                   System.out.println("In d code dl=" + xmldl + "aflag=" + aflag +"bflag=" + bflag + "cflag=" + cflag + "dflag=" + dflag);
              } // ends d if
              //If D line sets it to true then this will never run
              if((fbyte == ' ') & (dflag == true)) {
                   xml_dline.add("<action>" + line.substring(1, line.length()) + "</action>");
              }     //end if line length greater than zero
         }// ends handle     
         public static void store_old_dl(String line) {
              dlold = line.substring(3,11);
         public static void dlxmlwriter(){
    xmlwriter("<dl_record>");
         xmlwriter(xmldl);
         xmlwriter(xmlfobates);
         xmlwriter(xmltypeappdate);
         xmlwriter(xmlreq);
         xmlwriter(xml_issue_date);
         xmlwriter(xml_first_name);
         xmlwriter(xml_middle_name);
         xmlwriter(xml_last_name);
         xmlwriter(xml_dmvinfo);
         xmlwriter(xmlbday);
         xmlwriter(xmlsex);
         xmlwriter(xmlheight);     
         xmlwriter(xmlweight);
         xmlwriter(xmleyecolor);
         xmlwriter(xmlhaircolor);
         xmlwriter(xml_licenseclass);
         xmlwriter(xml_licenseclassname);
         xmlwriter(xml_licenseissuedate);
         xmlwriter(xml_licenseexpiresdate);
         xmlwriter(xml_licenseext);
         xmlwriter(xml_licenserestrict);
         xmlwriter(xml_licensedup);
         xmlwriter(xml_licenseheld);
         xmlwriter(xml_licenseseq);
         int a = 0;
         while (a < xml_abstractline.size()) {
              xmlwriter(xml_abstractline.get(a).toString());
              a++;
         int a1 = 0;
         while (a1 < xml_abstract_item.size()) {
              xmlwriter(xml_abstract_item.get(a1).toString());
              a1++;
         int a2 = 0;
         while (a2 < xml_abstract_violationdate.size()) {
              xmlwriter(xml_abstract_violationdate.get(a2).toString());
              a2++;
         int a3 = 0;
         while (a3 < xml_abstract_convictdate.size()) {
              xmlwriter(xml_abstract_convictdate.get(a3).toString());
              a3++;
         int a4 = 0;
         while (a4 < xml_abstract_sectviolated.size()) {
              xmlwriter(xml_abstract_sectviolated.get(a4).toString());
              a4++;
         int a5 = 0;
         while (a5 < xml_abstract_statute.size()) {
              xmlwriter(xml_abstract_statute.get(a5).toString());
              a5++;
         int a6 = 0;
         while (a6 < xml_abstract_file_number.size()) {
              xmlwriter(xml_abstract_file_number.get(a6).toString());
              a6++;
         int a7 = 0;
         while (a7 < xml_abstract_location_or_arn.size()) {
              xmlwriter(xml_abstract_location_or_arn.get(a7).toString());
              a7++;
         int a8 = 0;
         while (a8 < xml_abstract_vehicle_license.size()) {
              xmlwriter(xml_abstract_vehicle_license.get(a8).toString());
              a8++;
         int d = 0;
         while (d < xml_cline.size()) {
              xmlwriter(xml_cline.get(d).toString());
              d++;
         int e = 0;
         while (e < xml_dline.size()) {
              xmlwriter(xml_dline.get(e).toString());
              e++;
         int f = 0;
         while (f < xml_reqNameAddress.size()) {
              xmlwriter(xml_reqNameAddress.get(f).toString());
              f++;
         dflag = false;
         //writes the entag for dlnumber and dl record
    xmlwriter("</dl_record>");
         xml_abstractline.clear();
         xml_cline.clear();
         xml_dline.clear();
         xml_abstract_item.clear();
         xml_abstract_violationdate.clear();
         xml_abstract_convictdate.clear();
         xml_abstract_sectviolated.clear();
         xml_abstract_statute.clear();
         xml_abstract_file_number.clear();
         xml_abstract_location_or_arn.clear();
         xml_abstract_vehicle_license.clear();
         xml_reqNameAddress.clear();
         public static void xmlwriter(String writestring){     
              String filename = "U:\\dl.xml";
                   try {
                        FileWriter myFW = new FileWriter(filename, true);
                        BufferedWriter out = new BufferedWriter(myFW);     
    out.flush();
                        out.write(writestring);
                        out.newLine();
                        out.close();
                   } catch (IOException f) {
                        System.out.println("Error -- " + f.toString());
                   }// ends catch
    //     convenience to save typing, keep focus
         private static

    Ok, here is the snippet that I think is having problems
    static void xmlwriter(String writestring){
    String filename = "U:dl.xml";
    try {
    FileWriter myFW = new FileWriter(filename, true);
    BufferedWriter out = new BufferedWriter(myFW);
    out.flush();
    out.write(writestring);
    out.newLine();
    out.close();
    } catch (IOException f) {
    System.out.println("Error -- " + f.toString());
    }// ends catch
    I call this for everyline written, and as I watch the file bytes count up, I then see it reset to zero and start over. Could this be something to do with creating a new buffer for every line?

  • Cannot install PhotoShop CC "Error writing to temporary file location", how do I fix this?

         I am working on a Mac OS X Server, version 10.6.8
         I use my Adobe applications - Indesign, PhotoShop, Illustrator, and a couple of others - primarily for school work (graphic design). I download the applications from my Adobe Application Manager, but they recently stopped working. I didn't know if this was due to recent updates or the fact that I had just changed out my hard drive when the original one failed. I uninstalled the applications, and am trying to re-install them, but am receiving the error message, "Error writing to temporary file location".
         Does anyone know how to fix this? Is it just because I'm running 10.6.8? If so, can I make my applications work without getting a whole new computer?

    Please refer PS system requirements from this link:
    http://helpx.adobe.com/photoshop/system-requirements.html#Photoshop CC system requirements/
    Regards,
    Ashutosh

  • Problem in writing to the file

    I use this labview code to read and save some electrical measurement data from a set of instruments. I am having a problem that the code stops writing to the file after a while. It stops responding too. The only way to stop it then is to use the task manager and kill it. The code was written for an older version of labview but now I am using labview 9. Everything else seems updated but there's a section that uses Write characters to file vi and that may be causing the problem. I made a few futile attempts to change it. I would highly appreciate if someone takes a look at it and could tell me what's going wrong.
    Attachments:
    JANUS 2.2_4K Probe edit (2).vi ‏60 KB

    I will second aeastet's advice - please look into how state machines and producer/consumer loops work and use them.  Your program is very inefficient, but is very similar to what I would have written before I learned about state machines and producer/consumer loops.  Start with the LabVIEW help and go from there.  These forums and the National Instruments website can give you lots of help.
    Two things that will help you for this particular problem:
    At every loop iteration, you are opening the file, seeking to the end of it, appending data, then closing the file.  This is very slow and the code you use, as mentioned above, will not work if the file size exceeds 2GBytes.  I would recommend you open the file once, then use the write primitive to write to it until you finish, then close it.  You do not need the write character to file VI.  No seeking.  No repetitive opening and closing.  You can either open and close outside the loop, or use case structures and boolean flags (as you have done for other things) to open and close inside the loop.
    After you write to the file, if you choose to graph, you are reopening the file, reading the entire thing, and plotting this data.  This is another major slowdown that will only get worse as your file gets bigger.  You would be far better off caching the data in a shift register and plotting it on demand.  It would probably take less memory, as well.  You may want to read the tutorial Managing Large Data Sets in LabVIEW.
    One last tip.  You use Value properties to read and set the values of front panel controls.  Local variables are far faster (about three orders of magnitude).  However, do not make the mistake of using local variables for data storage.  Data is wires.  Local variables are a way to communicate to the front panel.  You seem to have this down, but a reminder to others reading this thread is in order.
    Let us know if you need more explanation or help.  Good luck!
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Writing a binary file

    Hi,
    I have trouble when writing a binary file. Here is what I do:
    I have some VI's collecting various data for a fixed period of time. I put all the data into 1D arrays at a fixed frequency (they all have the same size). Once it is done I merge all the arrays into one 2D array and I write that to a binary file. If I wait about 10 seconds after writing the file and I repeat the whole thing, everything is fine and the timing is correct. If I wait for a shorter period of time (say a sec, and this is the maximum I can wait to have a usable application) then the timing is wrong in the first part of the loop (the time-critical data-acquisition one). Of course, if I don't write the file, everything is fine (I have to wait about 250 msec between two runs, but that's ok). Any advice ?
    I also tried several things like streaming the data to disk during the time-critical period and this works fine only if the file allready exists. If not I experience jitters again. I don't really want to stream the data in real time, but it could work if I can get rid of the jitters. Again, any advice ?
    I'm using LV7.1 and the real time module running on a PC (ETS).
    Another, sort of related, topic: I noticed that when using 2D arrays within time critical loops all the process are slowdown whereas if I use several 1D arrays everything is fine... Any idea why ?
    Thanks,
    Laurent

    Hello,
    File I/O transfer rates during streaming to disk depends on several factors: CPU speed and load, hard drive technology (IDA / Serial ATA / SCSI ...), quality of programming. High jitter is always due to bad programming. File I/O operations are not deterministic. So, file I/O VI's must not be called in the critical task. Data must be saved in the normal priority VI's in order to keep jitter as low as possible. This is the reason why an application in RT is based on RT FIFO to transfer data from the critical loop and the normal priority VI.
    You will find a lot of tutorials detailing the key concepts for RT programming at the link below:
    * Real-Time Module
    http://zone.ni.com/devzone/devzone.nsf/webcategories/C25F8C664230613A862567DF006ABB06
    Moreover, memory allocation in LabVIEW is implicit. You must use large set of data carefully because some function reallocate new buffers for their outputs instead of reusing the input buffers (like the function "build an array"). You will find an example of how we can decrease the memory use with array in LabVIEW in the tutorials linked above.
    If you need more specific advices, you can post a sample code that reproduce the behavior that you does not understand. I will try to look at this and give you my feedback.
    Sincerely.
    Matthieu Gourssies, NIF.

  • Error writing metadata to file

    I am getting constant error messages from Bridge CS4 when trying to add keywords to my images "Error Writing Metadata to file "XXXX". It's very annoying and destroying my workflow. I have tried resetting original preferences, and using purge cashe. Finally I reorganized my entire folder structure which seemed to make the problem less frequent.
    The circumstance that makes this error pop up most frequently is when I add keywords to a handful of files that already have another keyword assigned. Quitting the folder and then re-entering it solves the problem for the photos with the current error, but then 20 or so photos later I get the error message again.
    Any Fixes?

    A new suspicion was that the read/write data might be different for the images files themselves than it was for the folder holding them. So I applied the read/write permission to the image files themselves. No luck though. Still getting "Error writing metadata to file xxxx" Errors. Would love to be spending all this time editing photos instead of chasing down bugs. Brand new MacBook Pro and I'm spending more time trying to fix errors than using the software. ::sigh::

Maybe you are looking for