सबसे पहले, मैं इस प्रश्न को वापस लाने के लिए क्षमा चाहता हूं, लेकिन मुझे लगा कि यह एक और जवाब का उपयोग कर सकता है।
डेरेक शल्ट्ज सही प्रकार का है। '\ B' चरित्र प्रिंटिंग कर्सर को एक वर्ण पीछे ले जाता है, जिससे आप उस प्रिंटर को ओवरराइट कर सकते हैं जो वहां मुद्रित था (यह पूरी लाइन या यहां तक कि उस चरित्र को तब तक नहीं हटाता जब तक आप शीर्ष पर नई जानकारी प्रिंट नहीं करते)। निम्नलिखित जावा का उपयोग कर प्रगति पट्टी का एक उदाहरण है, हालांकि यह आपके प्रारूप का पालन नहीं करता है, यह दिखाता है कि ओवरराइटिंग वर्णों की मूल समस्या को कैसे हल किया जाए (यह केवल 32-बिट मशीन पर ओरेकल के जावा 7 के साथ उबंटू 12.04 में परीक्षण किया गया है, लेकिन यह सब जावा सिस्टम पर काम होना चाहिए):
public class BackSpaceCharacterTest
{
// the exception comes from the use of accessing the main thread
public static void main(String[] args) throws InterruptedException
{
/*
Notice the user of print as opposed to println:
the '\b' char cannot go over the new line char.
*/
System.out.print("Start[ ]");
System.out.flush(); // the flush method prints it to the screen
// 11 '\b' chars: 1 for the ']', the rest are for the spaces
System.out.print("\b\b\b\b\b\b\b\b\b\b\b");
System.out.flush();
Thread.sleep(500); // just to make it easy to see the changes
for(int i = 0; i < 10; i++)
{
System.out.print("."); //overwrites a space
System.out.flush();
Thread.sleep(100);
}
System.out.print("] Done\n"); //overwrites the ']' + adds chars
System.out.flush();
}
}
कैरिज रिटर्न एस्केप अनुक्रम '\ r' 2004 में रिपोर्ट की गई [पुरानी बग] (https://bugs.eclipse.org/bugs/show_bug.cgi?id=76936) की वजह से एक्लिप्स में काम नहीं करता है और निश्चित नहीं है अभी तक ग्रहण के अंतिम संस्करण (4.3.2 केप्लर) –
में यह केवल एक पंक्ति के लिए काम करता है? –
@Sortofabeginner: एक शब्द में, हाँ। – NPE