is it possible to clear the content in .txt file??
in
Programming Questions
•
10 months ago
I would like to know if it is possible to clear .txt file(without closing and open new createwriter() with the same file name)..??
If it possible, how to do it??
Im writing some 3 values of x,y,z position into txt file for 150 frame every 5 seconds(means 3x150 data in 5 seconds)..and I would like to clear those values as I wont be using it in the next 5 seconds or so..if I dont clear the values, the size of the txt file will continue to increase, and I would like to avoid that to happen..
I tried using arraylist to store those 3 values for 150 frames and then clear the contents by clear()..but the output visual becomes stiff and not smooth(I got about 80 frames in 5 seconds instead of 150)..so Im thinking of saving those values for a while in txt file and read the values from it..
Is there any other way to achieve what Im trying to do??Sorry,this would be second question..
it wont be any help but Ill put my code(necessary part) below anyway just in case
If it possible, how to do it??
Im writing some 3 values of x,y,z position into txt file for 150 frame every 5 seconds(means 3x150 data in 5 seconds)..and I would like to clear those values as I wont be using it in the next 5 seconds or so..if I dont clear the values, the size of the txt file will continue to increase, and I would like to avoid that to happen..
I tried using arraylist to store those 3 values for 150 frames and then clear the contents by clear()..but the output visual becomes stiff and not smooth(I got about 80 frames in 5 seconds instead of 150)..so Im thinking of saving those values for a while in txt file and read the values from it..
Is there any other way to achieve what Im trying to do??Sorry,this would be second question..
it wont be any help but Ill put my code(necessary part) below anyway just in case
- //if we're recording tell the recorder to capture this frame
- if(recording){
- recorder.recordFrame();
- PVector recordedNeck2 = recorder.trackedJoints[0].getPosition().position;
- PVector recordedLeftShoulder2 = recorder.trackedJoints[1].getPosition().position;
- PVector recordedLeftElbow2 = recorder.trackedJoints[2].getPosition().position;
- PVector recordedLeftHand2 = recorder.trackedJoints[3].getPosition().position;
- PVector recordedRightShoulder2 = recorder.trackedJoints[4].getPosition().position;
- PVector recordedRightElbow2 = recorder.trackedJoints[5].getPosition().position;
- PVector recordedRightHand2 = recorder.trackedJoints[6].getPosition().position;
-
- saveData(oLeftHand,recordedLeftHand2);
- saveData(oNeck,recordedNeck2);
- saveData(oLeftShoulder,recordedLeftShoulder2);
- saveData(oLeftElbow,recordedLeftElbow2);
- saveData(oRightShoulder,recordedRightShoulder2);
- saveData(oRightElbow,recordedRightElbow2);
- saveData(oRightHand,recordedRightHand2);
-
- stop(oNeck);
- stop(oLeftShoulder);
- stop(oLeftElbow);
- stop(oRightShoulder);
- stop(oRightElbow);
- stop(oRightHand);
- recorder.nextFrame();
- }
- if(millis() >= timer+5000){
- timer = millis();
- recording = !recording;
- String rows[] = loadStrings("C:\\data\\nameofactivity\\1st\\LeftHand.txt"); //check if we are able to read while the txt is still opened
- println(rows.length);
- }
- void saveData(PrintWriter output, PVector jointID){
- output.println(jointID.x + " " + jointID.y + " " +jointID.z);
- }
- void stop(PrintWriter joint){
- joint.flush();
- /////////joint.close();
- }
1