8 Replies - 879 Views - Last Post: 19 March 2008 - 02:17 PM Rate Topic: -----

#1 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Character encoding in output

Posted 03 March 2008 - 03:19 PM

I'm trying make a program that will cut text files into smaller pieces. Well, I'm getting there but the problem is, when I typecast what is returned from the .read() method (how does typecasting ints turn them into letter characters?), they don't come out the way they are supposed to. I suppose it's a character encoding issue, but I don't know what to do. Here's my code:
import java.io.*;
import java.util.*;

public class BookToPod
{
	public static void main(String[] args) throws IOException
	{
	
		String fileName;
		//This boolean returns true if the user has given only a file
		//(for example "text.txt") or false
		//if the use gives a path (for example "dir/stories/text.txt")
		boolean fileOnly = true;
		File text;
		BufferedReader reader;
		BufferedWriter writer;
		char[] buffer = new char[4000];
			
		Scanner input = new Scanner(System.in);
		System.out.println("Welcome to the Pod Book program.");
		System.out.println("By default, this program will search in /home/test/Documents.");
		System.out.println("The file(s) will be saved in /home/test/Documents.");
		System.out.println("\nEnter a file to convert.");
		
		fileName = input.next();
		//Searches to find a directory seperator. If it's found, then
		//the input is a file path
		for(int i = 0; i<fileName.length();i++)
		{
			if(fileName.charAt(i)=='/')
			fileOnly = false;
		}
		//If only a file is given, search, by default, in /home/test/Documents
		if(fileOnly==true)
		{
			text = new File("/home/test/Documents/"+fileName);
			reader=new BufferedReader(new FileReader(text));
		}
		else
		{
			text = new File(fileName);
			reader=new BufferedReader(new FileReader(text));
		}
		

		if(text.exists())
		{
			int i = 0;
			while(reader.read()!=-1 && i<4000)
			{
				
				buffer[i] = (char)reader.read();
				i++;
			}
			System.out.println(buffer);
		}
		else
		{
			System.out.println("Sorry. The requested file was not found in this location.");
		}
		
		
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Character encoding in output

#2 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Character encoding in output

Posted 03 March 2008 - 03:22 PM

Could you please post the contents of the file?
Was This Post Helpful? 0
  • +
  • -

#3 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Re: Character encoding in output

Posted 03 March 2008 - 07:19 PM

Okay, here it is. Don't laugh, it's Avatar: The Last Airbender fanfiction.

---

 

Chapter 6: What’s in a Master?

 

---

 

		  A few evenings after leaving Kutan, Sokka busied himself over some maps. “Okay, so Bumi told us… he said it was this island,” Sokka said, pointing to one of the islands of the Southern Air Temple.

		  Aang stood from Appa’s head and hopped weightlessly into the saddle. Then he leaned over Sokka’s shoulder and identified, “That’s Whale Tail Island. See the shape?” 

		  “You know it?” Zuko asked, curious and slightly surprised.

		  “Sure,” Aang replied, smiling at some distant memory. “We – the monks and some of the other kids – went there sometimes. There was a temple there… a big one, and no one ever went inside. And since temples were pretty common, no one thought to ask about it.” Aang shrugged. “Could be the place Kanaye’s going for. I’ve never been inside of it, so I don’t know what its like.”

		  Katara nodded steadily, taking in the information. Sokka made no move to say that he’d heard the Avatar; he was studying the map, and every now and then he would glance up at the sky. He sighed, preparing to deliver news. “The only way we’ll be able to get to Gaoling before the Shinsei is if we go through the mountains.”

		  Katara looked toward the triangular shapes on the horizon. If they continued in that direction, they were sure to face turbulence; the sky was colored a deep, ugly purple, reminiscent of a bruise. “That’ll bring us through bad weather. Are you sure the mountains won’t be too dangerous? Is there a safer way?”

		  “We could go around them, but that would make us at least three days late. We just can’t afford it.” Sokka shook his head; Toph stayed silent, as she had been all day. He worried about her but directed his face to Katara, waiting for her response.

		  Katara said nothing, knowing that despite the dangers of the mountains, worse things would lurk on the other side. She licked her lips and nodded, hoping that the Spirits would keep them out of harm’s way.

		  Hours passed, and they did so in silence; Katara had busied herself with repairing a few tears in the sleeping bags, Zuko was sitting as far away from them as possible and doing nothing, Aang was driving and offered the occasional nervous remark in regard to the weather, Sokka switched between scrutinizing the maps and pretending to read some scrolls, and Toph did nothing and said nothing. From time to time her hand would drift to her arm and she would touch the meteorite bracelet, but other than that, she was still.

		  Eventually Sokka had to stop pretending. He’d read one sentence eighteen times and he still didn’t know what it said; his mind was elsewhere. Toph was unsettled, and even if it wasn’t really any of his business (but since when did that matter?), he wanted to be helpful. After putting his scrolls aside he scooted beside her. 

		  Her expression changed from thoughtful and slightly sad to slightly puzzled, but she did not otherwise acknowledge him. This was fine with him; he was content to sit in silence, but he thought to offer a few comforting words first. “They’ll be ok-”

		  Quite suddenly a crack of lightning split the sky, and a mere moment later thunder ripped it apart. Sokka glanced at Toph for a moment and then sprang to his feet, hoping to help Aang keep direction. 

		  Toph was unnerved; she held her fright well, but afraid she was. She hated storms anyway (loved the rain, but hated thunder and lightening), and she was vulnerable in the air. It was unknown territory. She felt safe on Appa, but that security was shattered by lightening and scattered by the roar of thunder. Toph very rarely felt small – but storms had that effect on her, and it wasn’t easily accepted. 

		  Another thing that contributed to her particular dislike of storms in the air was the fact that sometimes even Appa was frightened by them. He was more accustomed to it, and perfectly at home in the air, but particularly bad storms made his heart jolt much faster than necessary.

		  Katara moved toward Aang, taking Sokka’s place; they were discussing whether or not if would be safe to fly higher, into the clouds, and bend a clear path for them. They’d only done it once before, and never with such a large storm, but they were unsure of whether or not they’d be able to make it through.

		  Sokka shifted back to his place beside Toph, and as he did so, another jagged bolt of lightening descended from the sky and emitted a deafening crash. Appa, surprised and frightened by the noise, became unstable and shifted dangerously to one side. The movement caught Toph by surprise and she fell out of the saddle, clinging to the bison’s fur just out of Sokka’s reach.

		  It began to rain.

		  Toph, terrified, clutched Appa’s matted fur with every bit of strength she had. Her hair began to stick to her face, and Sokka and Zuko both tried to reach her, but she was just beyond their grasps.

		  Appa shifted again, and Toph screamed; Sokka found himself pitched forward, as close to her as he could get, and he grabbed her wet forearms. She was slippery and would have easily escaped his grasp save for how tightly he held her. Then he began to pull up, and, because she trusted him and because she had to in order to make progress, she relinquished her grip on Appa’s fur.

		  With a little help from Zuko, Sokka pulled her into the saddle. Katara, alarmed, immediately instructed Aang to get out of the mountains. If they went down, there was no telling where they might end up, and she didn’t want to risk another thunderclap disturbing Appa. They needed fair weather, whether it would put them three days behind or not.

		  “You should be more careful,” Zuko told Toph, sitting a couple of feet away. He didn’t seem to trust her enough to let her be too far away. She felt like he was treating her like a child, but at least he was pitiless; that was why she liked Zuko. He wasn’t apathetic, but he never felt sorry for anyone. His own experiences had made sure of that – if he could endure what had happened to him, then as far as he was concerned anyone should be able to conquer their own experiences, however brutal.

		  Toph scowled at Zuko; she was the greatest earthbender in the world! He, merely the Fire Lord (she scoffed inwardly at the thought), had no right to treat her like a simple misguided child. Sokka said nothing. He knew she would be ashamed of herself for not clinging to the saddle. She’d broken that habit some time ago, trusting Appa; however, she knew that the trust was ruptured, even if only temporarily.

		  Her injured pride prevented her from taking Sokka’s arm, which he offered, until the skies were nearly clear; at this point, however, she asked, “Is the storm over? Completely?”

		  Katara hadn’t told her about the change in course, and she really wasn’t looking forward to it. “Well, Toph…” she began, looking to Aang for support. He was turned toward her, hands still on the reins. 

		  “Yes, it’s over. But only because we’re not in the mountains anymore,” Aang said, his voice cautious.

		  Toph seemed to digest this information. “We left the mountain path,” she stated. “We’re not going to make it in time.” She was telling herself rather than clarifying it to the others. 

		  They continued that path, keeping parallel with the storm clouds that continued to hang over the mountain peaks and never seemed to end.

 

-The Morning of the Third Day-

 

		  “I think I can see Gaoling,” Aang said, trying to be helpful. “We’re nearly there.”

		  Katara turned to see if she could also see the city, and indeed, she could make out some sort of settlement on the horizon. The waterbender frowned. “I can see it, too, but what’s that down there? That… cloud of dust?”

		  Aang shrugged. “Since it’s too wide to go around, I figure if we keep high enough we won’t have to worry about whatever it is. We should reach the city soon.”

		  As Appa began to pass over the dust cloud, just making it past the boundaries, Toph’s keen ears caught a sound. “Wait, stop. Go back.” Her eyes widened slightly. “Aang, turn Appa around.”

		  Aang seemed uneasy. “He thinks we should turn back, too. Okay, buddy…” Momo chirruped uncertainly, standing from where he was laying in Katara’s lap and moving about nervously. As Appa made to turn, something appeared at the corner of Aang’s vision – red…

		  “Get us out of here!” 

		  No one knew who said it, for the voice was indistinguishable among the sear of fireballs erupting from the dust cloud. Aang had been sure that they were flying high enough; certainly they were at an elevation beyond what any firebender would be able to launch an attack. As they began to retreat, the dust started to settle – and Aang turned back to see the benders and noticed that they were all standing on tall columns, so they hadn’t been shooting from the ground.

		  Suddenly the columns pitched forward; the firebenders began to earthbend forward, reminding Sokka and Aang of how Toph had used earthbending as means of travel when they picked her up on their way back to Ba Sing Se. Toph herself could hear them loud and clear – and easily recognized that they were skilled from the mere sounds of their bending. 

		  There were definitely too many of them to fight – a line of them stretched out along the horizon, though not to the very edge of it. Perhaps there were five-hundred, perhaps a thousand – the number couldn’t be estimated. If they truly were masters of all the elements, they were a force to be reckoned with, most certainly. They accelerated at stunning speeds, catching up with the air bison. 

		  Katara inhaled deeply. “They’re airbenders, Aang,” she murmured, lightly touching his shoulder. “It doesn’t matter how high we go, because they’re able to do it, too.” The Shinsei never seemed to stop accelerating – they were blurs, and there was a steady, earthy hum as they pursued the Avatar and his companions.

		  “They don’t have gliders,” Aang said in reply, though his voice audibly shook with his lack of confidence in this statement’s truth. 

		  Katara simply shook her head. “We don’t know that. We don’t know what they’re capable of. Running, that’ll get us nowhere.” She strained her voice so that the others passengers could hear her. Sokka perked to her words.

		  “He won’t kill us yet. He’s… testing us, I bet,” he offered, peering over Appa’s saddle with a scrutinizing expression. “Maybe he’s trying to scare us. Maybe he wants us to fight. I don’t know, but I’m pretty sure that whatever his plans are, he’s put more thought into it than just killing us outright.”

		  “Does he want to capture us, then?” Zuko asked. As the conversation continued, Appa continued to climb higher; his sloping ascent began to level, and the Shinsei continued pursuit. Despite Appa’s speed and the assistance of air travel, they were almost directly below the Avatar, preparing for whatever Kanaye had in mind.

		  Sokka’s frown defined considerably; he never took his eyes off the figures below them. “Maybe. Maybe that is what he’s doing.” The warrior shook his head, wondering at the enemy’s plans. “We shouldn’t just wait around and let him strike first, though. That might work for Toph, but we have to get the edge on this fight quick – I feel like we’re doing just what he wants.”

		  Aang turned to him and nodded solemnly. “We’ll stand and fight,” he said simply, and the others silently agreed. He encouraged Appa to turn as quickly as he could so that he might get behind the Shinsei to land – that way the Shinsei wouldn’t stand between the Avatar’s group and Gaoling.

		  Appa turned abruptly and the Shinsei, obviously at least a little surprised by this, began to turn around as well. They worked in one synchronized motion to accomplish a sweeping turn for the purpose of keeping their momentum. Appa was flying very fast, but he began to slow as he prepared to land; they were far enough away from the Shinsei to get off of Appa and prepare for the fight ahead. It was obvious that they wouldn’t be allowed any sort of rest until the Shinsei had accomplished whatever it was that they wanted, and so, because Appa’s speed was no match for the powerful speed of their bending, and because using the shelter of Gaoling (if they could make it there) would only endanger the citizens, fighting was the only other option. Well, there was giving up – but since when did the Avatar and his companions ever resort to that?

Appa’s feet touched the ground; Aang airbended himself and Katara off, and Toph, Sokka, and Zuko joined them moments later. Each prepared in his or her own way – Aang steadied himself, Katara drew water from the container at her side, Zuko loosened himself up and allowed flames to dance in his hands, Sokka drew his sword, and Toph – Toph’s toes flexed, measuring their approaching adversaries; her muscles tensed, waiting, just waiting for one of them to make the first move. She would counter – and she, fueled by a flame more common in short-tempered firebenders, was more than ready to exchange her anger for the adrenaline-pumping thrill of battle. She needed to fight.

		  In the blink of an eye, the Shinsei were upon them; such a straightforward attack shook the others’ steadiness, but Toph’s fighting was so perfectly composed in the very beginning that it seemed the fight between she and her opponents had been rehearsed.

		  Toph held the heels of her hands together and thrust forward boulder; in the time it took her to perform that single movement a thread of flames, flurry of earthen daggers, and gust of strong wind came at her from three different opponents. To stay focused in battle they could only bend one element at a time – Toph resolved that their speed during their pursuit had only been a combination of airbending and earthbending because they hadn’t really had to focus on their actions. She had little time to think, though, before she was forced to make a wooden shield burst from the ground to deflect a fire blast.

		  The only water around belonged to Katara, so the Shinsei were unable to waterbend. This small comfort was barely worth it, but at least Katara’s bending was unique; Zuko, too, had a small advantage since there was no water to put out his flames, though earthbending was still against his particular element. The Shinsei, to everyone’s surprise, had no armor – at least none that they could see (or feel through vibrations), and this was slightly comforting, too.

		  Toph noticed that only a small number had engaged in combat – fifteen fought against them, and the others kept a respective distance. This was a curious thing to Toph, but she knew that if every one of them had been fighting them, they wouldn’t have had a prayer – whether death was Kanaye’s intention or not, that was undoubtedly what would have happened. It would have been inescapable.

		  Toph quickly resolved that Kanaye wanted them to live, and, with this relief engulfing her, her motions were more fluid. Fighting three people was difficult, but whatever happened, they would all, most likely (for she was never sure of anything), make it out alive. Then she could go to Gaoling and see if Kanaye had spared them, killed them, or captured them – she wouldn’t be able to save them, not yet.

		  She made the ground beneath the one currently earthbending tremble and slide uncertainly. He would have done the same to her, but she had utter and complete control of the earth around her – none of them could turn her native element against her, no matter how hard they tried. They could throw rocks at her all they wanted, but their mastery of the earth was no greater than hers; because, too, they weren’t capable of their own wills and couldn’t have faults or feel emotions, they couldn’t feel a connection with that element. Earth was not special to them – it was a skill, and that was all. That was why she could so easily throw the earth out from under each of them but they had no hope of taking away her power of her element.

		  She could feel the strength of the earth resonating beneath her and flowing into her, through her. She knew at once that they could feel no such thing – they might be masters in one sense of the word, but they would never understand any of the four elements, and for a brief moment Toph felt sorry for them.

		  Then her mind returned to the fight at hand.

		  Each of her opponents was an equal distance away from her and from each other. She was in the center of them, and decided to use this to her advantage. While they each sent a blast of fire at her at once, she encased herself in a strong, sturdy rock shell shaped like a triangular pyramid. When she first felt the pressure of the benders’ blasts against her shell, she used as much strength as she could muster to send three slabs of rock that composed her casing flying at the Shinsei. The slabs were so strong that instead of shattering against the blast of the fire, they bore the flames backward, and her Shinsei opponents were both burned and beaten by her attack.

		  The first composed himself quickly and sent a whirlwind at her; she sent earthen discs at it for the purpose of slowing it down and weakening its power, and as the remaining light, airy breeze passed over her, she stomped the ground and sent a slanted pillar at the second recovering Shinsei, hurling the woman back. The third used this moment to attack her from behind and punched a succession of fireballs at her. She took the first one, but the others were extinguished by a boulder the ground choked up for her. She sent it flying at the man, and his attacks were futile as the rock hit him square in the chest. He fell, dazed and perhaps mortally wounded, though that depended on the hit.

		  The second was still winded, and that just left Toph with the first. While he was at the same skill level as the other two, he was much faster – and therefore much more of a challenge. She evaded or countered his attacks, and she had yet to throw a blow herself; she was trying to wear him out, but his breathing was always steady. It seemed as though she Shinsei had a never-ending supply of energy.

		  Aang still had all three of his opponents, but he was matched equally with all of them, and he felt a connection with each of the elements he worked with. Because they had no such connection, he was doing very well. He wasn’t powered by anger, as Toph had been, but by a steadily growing flame that gave him the ability to do nothing more than grow and do better – the Shinsei could do no such thing, and had no particular strategy. If ever they seemed to have forethought their attacks, it was just luck on their part.

		  Katara was fighting two. One had intended to rob her of her water, but she quickly got rid of him; just as the Shinsei had not been able to make Toph relinquish her power over the earth beneath her, so were the Shinsei not able to rob Katara of the part of her element over which she had control. Katara handled her water with unmatched grace and elegance which the Shinsei seemed to have none of; Katara had many advantages.

		  Zuko found power for his attacks in his passion for his country and its safety; these monsters would act to control the Fire Nation, and then the world – and they had no right to any of it, least of all what he and the Avatar had earned. These creatures were thoughtless, careless – they were nothing, and if there could be something more despicably valueless, they would have been such. These unnatural evils had no right to anything. How dare Kanaye use these things to bring himself into power? How dare he? Zuko’s passion flowed from his body to the fire that sprang from his fingertips and palms. His motions were precise – he fought with as much strength as he could find. He was hindered by nothing and no one. He had one man left to defeat, and he intended to do so.

		  Sokka, well – if anyone besides Toph had been more than semi-conscious of Sokka’s accomplishments, they would have been pleasantly surprised. Sokka was perhaps the most skilled non-bender, it was true; his weapon prowess was unmatched. He sometimes found it difficult to fight benders because they could attack from good distances, out of reach of Sokka’s sword, but even then he fought well. This time, though, he had been presented with three benders, and each a master of all four elements. This was sure to have been one of the most challenging fights he had ever engaged in; yet, despite the horribly unfavorable odds, he was constantly completely aware of the stakes – and he fought brilliantly. While the black sword he bore did not have the ability to strike fear in the hearts of his opponents, as it would have if his adversaries had been capable of emotion, he was nonetheless outstanding in battle. He was quick and easily dodged almost every attack the Shinsei could throw at him – and he didn’t hesitate to put his weapon to use every time the Shinsei came close. Even after mortally wounding one (the man suffered a horrifying blow to his arm and was barely alive because of blood loss), the other two had no fear of the black sword and its bearer. Sokka pierced a second bender in his chest; he was not unused to such brutality, but he would never really feel accustomed to it. He could murder a countless number of people and his heart would always pound with the knowledge of his actions, the pure, basic reality of what he’d done. He was horrified at himself, but all the same, when he fought the enemy there was always a thrill in it, too. 

		  Sokka’s third adversary was a woman. Once upon a time he might have refused to fight her; but he had grown into the habit of turning aside the knowledge of gender to embrace the knowledge of the enemy’s identity. Being a female had absolutely nothing to do with how evil a person’s intentions were, as Azula so skillfully proved, and so Sokka had no problem fighting her, though maybe, a long time ago, he very well would have.

		  Toph was making little progress. The man she faced was much faster than her; he expertly manipulated his elements. Toph’s insides burned at that word – manipulate. It was a horrible, disgusting word to describe the handling of one’s element, but that was exactly what he was doing. He was making his lack of a bond with the earth, with fire, with air so painfully obvious that Toph felt another kind of rage, one that felt purer and more natural. How could this man be called a bender? He didn’t bend. He manipulated. He didn’t deserve to have any kind of control over an element. He did not appreciate. He did not love, did not live for the elements that he had mastered. Mastered! To be called a master was a privilege and an honor. He had no right to it, no matter how well he could manipulate. 

		  The connection between Toph and her element had been there from before birth; it was woven intricately and could never be broken. It would always be there, and Toph hated – purely hated – how someone like him had the audacity (though he had no audacity) to call himself a master. How sickening! She searched in vain for any way that he might use to establish that indeed there was a connection; but while he moved with utter certainty, he did not move like an earthbender. While his motions were fluid, they did not have the honorable semblance to those of a waterbender. While his attacks were precise, they were not remotely reminiscent of those a firebender might perform; while he himself was light and loose and he executed his hits so naturally and easily, he could never, ever be considered an airbender. He was merely an imitation of each of these things. He was a sick, filthy imitation – he was nothing real. He was not a person, but a lowly being not even worthy of a name.

		  This hate consumed Toph, and her attacks became unbearably powerful. Her final adversary fought on, unheeded at first, but finally his bruised, battered body was swallowed by a chasm, and the earth choked him down; his empty eyes would never again be graced with sunlight, but with darkness until life drained from him body. Toph found sick satisfaction in that and quickly helped the others vanquish their opponents; the Shinsei that had not been pitched into battle at the beginning still kept their distance, not looking at the battle because their eyes had no interest.

		  Soon enough the Avatar’s companions were victorious, in a bittersweet way. Their test was over. They had survived – they were bruised, beaten, bleeding, battered, broken in several places, but most of all they were gloriously alive, and that was all that truly mattered. They were alive and they had identities, they had emotions and faults. They had their elements, and that was all they would ever need.

		  Their ears rang, though the sounds of battle had faded some time ago. The area around them was horrifying – the ground was practically ripped apart in some places, and whatever grass might have been there before was long gone now. Silence reigned for a few beautiful moments.

		  The Shinsei, in one swift movement, all turned away from the Avatar and companions and began to earthbend away, leaving a conspicuous path behind them. One man, however, blew a gust of air at them, and as he turned to leave, a folded piece of parchment landed on the ground at their feet. Toph felt the tiny vibrations as it landed and felt uneasy; the others did, too. Since no one else seemed too keen to pick it up, Sokka bent and took the parchment between his thumb and forefinger. He unfolded it and began to read what it said; the more he spoke, the lower his voice got. His voice was dangerously grave as he spoke the last word, the signature.

		  Youths, 

		  You have impressed me with your talented fighting. It was my first time seeing the Shinsei in a real battle, and allow me to say that now that I am aware of their power, I am better equipped for the events that are to follow. Hopefully you will learn of these events soon enough. Hopefully by now you’re aware that if you barely succeeded against the Shinsei on this day, you have yet to experience the true strength of the entire army. I merely wished to see your talents and the skill of the Shinsei, and I suppose I did you a favor in showing you exactly what you’re against.

		  I was especially pleased to be able to finally see the greatest earthbender in the world fight my benders. I have great plans for you, Toph. I suppose at this time you are wondering about your parents – I am more than happy to oblige. I shall not tell you of their fates just yet. You will learn soon enough.

		  Phase two of Toph’s destruction is on the horizon. Keep it in mind.

		  Yours,

Kanaye

 

-

 

End

 

-


Was This Post Helpful? 0
  • +
  • -

#4 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Character encoding in output

Posted 03 March 2008 - 07:49 PM

Here is the code. I have made some changes only for my testing purpose, but they are undo-able. :)

import java.io.*;
import java.util.*;

public class BookToPod
{
    public static void main(String[] args) throws IOException
    {
    
        String fileName;
        //This boolean returns true if the user has given only a file
        //(for example "text.txt") or false
        //if the use gives a path (for example "dir/stories/text.txt")
        boolean fileOnly = true;
        File text;
        BufferedReader reader;
        //BufferedWriter writer;
        char[] buffer = new char[4000];
            
        Scanner input = new Scanner(System.in);
        System.out.println("Welcome to the Pod Book program.");
        System.out.println("By default, this program will search in /home/test/Documents.");
        System.out.println("The file(s) will be saved in /home/test/Documents.");
        System.out.println("\nEnter a file to convert.");
        
        fileName = input.next();
        //Searches to find a directory seperator. If it's found, then
        //the input is a file path
        for(int i = 0; i<fileName.length();i++)
        {
            if(fileName.charAt(i)=='/')
            fileOnly = false;
        }
        //If only a file is given, search, by default, in /home/test/Documents
        //if(fileOnly==true)
        {
            text   = new File(fileName);
            reader = new BufferedReader(new FileReader(text));
        }
        //else
        /*{
            text   = new File(fileName);
            reader = new BufferedReader(new FileReader(text));
        }*/
        

        if(text.exists())
        {
            int i = 0;
            while  ( i < 4000-1 )
            {
            	 buffer[i] = (char)reader.read();
                //buffer[i] = (char)reader.read();
            	 //buffer[i] = (char)x;
                i++;
            }
            System.out.println(buffer);
        }
        else
        {
            System.out.println("Sorry. The requested file was not found in this location.");
        }
        
        
        
        
    }
}



The text file was causing the problems actually, if the text file is not in pure ASCII form, it will give you funny character with the buffer output.

quotes " and apostrophe ' should not be formatted like they are in MS Word or Open Office.

So here is the plain ASCII text file : (I think)
--



Chapter 6: What's in a Master?



---



		  A few evenings after leaving Kutan, Sokka busied himself over some maps. "Okay, so Bumi told us… he said it was this island," Sokka said, pointing to one of the islands of the Southern Air Temple.

		  Aang stood from Appa's head and hopped weightlessly into the saddle. Then he leaned over Sokka's shoulder and identified, "That's Whale Tail Island. See the shape?"

		  "You know it?" Zuko asked, curious and slightly surprised.

		  "Sure," Aang replied, smiling at some distant memory. "We – the monks and some of the other kids – went there sometimes. There was a temple there… a big one, and no one ever went inside. And since temples were pretty common, no one thought to ask about it." Aang shrugged. "Could be the place Kanaye's going for. I've never been inside of it, so I don't know what its like."

		  Katara nodded steadily, taking in the information. Sokka made no move to say that he'd heard the Avatar; he was studying the map, and every now and then he would glance up at the sky. He sighed, preparing to deliver news. "The only way we'll be able to get to Gaoling before the Shinsei is if we go through the mountains."

		  Katara looked toward the triangular shapes on the horizon. If they continued in that direction, they were sure to face turbulence; the sky was colored a deep, ugly purple, reminiscent of a bruise. "That'll bring us through bad weather. Are you sure the mountains won't be too dangerous? Is there a safer way?"

		  "We could go around them, but that would make us at least three days late. We just can't afford it." Sokka shook his head; Toph stayed silent, as she had been all day. He worried about her but directed his face to Katara, waiting for her response.

		  Katara said nothing, knowing that despite the dangers of the mountains, worse things would lurk on the other side. She licked her lips and nodded, hoping that the Spirits would keep them out of harm's way.

		  Hours passed, and they did so in silence; Katara had busied herself with repairing a few tears in the sleeping bags, Zuko was sitting as far away from them as possible and doing nothing, Aang was driving and offered the occasional nervous remark in regard to the weather, Sokka switched between scrutinizing the maps and pretending to read some scrolls, and Toph did nothing and said nothing. From time to time her hand would drift to her arm and she would touch the meteorite bracelet, but other than that, she was still.

		  Eventually Sokka had to stop pretending. He'd read one sentence eighteen times and he still didn't know what it said; his mind was elsewhere. Toph was unsettled, and even if it wasn't really any of his business (but since when did that matter?), he wanted to be helpful. After putting his scrolls aside he scooted beside her.

		  Her expression changed from thoughtful and slightly sad to slightly puzzled, but she did not otherwise acknowledge him. This was fine with him; he was content to sit in silence, but he thought to offer a few comforting words first. "They'll be ok-"

		  Quite suddenly a crack of lightning split the sky, and a mere moment later thunder ripped it apart. Sokka glanced at Toph for a moment and then sprang to his feet, hoping to help Aang keep direction.

		  Toph was unnerved; she held her fright well, but afraid she was. She hated storms anyway (loved the rain, but hated thunder and lightening), and she was vulnerable in the air. It was unknown territory. She felt safe on Appa, but that security was shattered by lightening and scattered by the roar of thunder. Toph very rarely felt small – but storms had that effect on her, and it wasn't easily accepted.

		  Another thing that contributed to her particular dislike of storms in the air was the fact that sometimes even Appa was frightened by them. He was more accustomed to it, and perfectly at home in the air, but particularly bad storms made his heart jolt much faster than necessary.

		  Katara moved toward Aang, taking Sokka's place; they were discussing whether or not if would be safe to fly higher, into the clouds, and bend a clear path for them. They'd only done it once before, and never with such a large storm, but they were unsure of whether or not they'd be able to make it through.

		  Sokka shifted back to his place beside Toph, and as he did so, another jagged bolt of lightening descended from the sky and emitted a deafening crash. Appa, surprised and frightened by the noise, became unstable and shifted dangerously to one side. The movement caught Toph by surprise and she fell out of the saddle, clinging to the bison's fur just out of Sokka's reach.

		  It began to rain.

		  Toph, terrified, clutched Appa's matted fur with every bit of strength she had. Her hair began to stick to her face, and Sokka and Zuko both tried to reach her, but she was just beyond their grasps.

		  Appa shifted again, and Toph screamed; Sokka found himself pitched forward, as close to her as he could get, and he grabbed her wet forearms. She was slippery and would have easily escaped his grasp save for how tightly he held her. Then he began to pull up, and, because she trusted him and because she had to in order to make progress, she relinquished her grip on Appa's fur.

		  With a little help from Zuko, Sokka pulled her into the saddle. Katara, alarmed, immediately instructed Aang to get out of the mountains. If they went down, there was no telling where they might end up, and she didn't want to risk another thunderclap disturbing Appa. They needed fair weather, whether it would put them three days behind or not.

		  "You should be more careful," Zuko told Toph, sitting a couple of feet away. He didn't seem to trust her enough to let her be too far away. She felt like he was treating her like a child, but at least he was pitiless; that was why she liked Zuko. He wasn't apathetic, but he never felt sorry for anyone. His own experiences had made sure of that – if he could endure what had happened to him, then as far as he was concerned anyone should be able to conquer their own experiences, however brutal.

		  Toph scowled at Zuko; she was the greatest earthbender in the world! He, merely the Fire Lord (she scoffed inwardly at the thought), had no right to treat her like a simple misguided child. Sokka said nothing. He knew she would be ashamed of herself for not clinging to the saddle. She'd broken that habit some time ago, trusting Appa; however, she knew that the trust was ruptured, even if only temporarily.

		  Her injured pride prevented her from taking Sokka's arm, which he offered, until the skies were nearly clear; at this point, however, she asked, "Is the storm over? Completely?"

		  Katara hadn't told her about the change in course, and she really wasn't looking forward to it. "Well, Toph…" she began, looking to Aang for support. He was turned toward her, hands still on the reins.

		  "Yes, it's over. But only because we're not in the mountains anymore," Aang said, his voice cautious.

		  Toph seemed to digest this information. "We left the mountain path," she stated. "We're not going to make it in time." She was telling herself rather than clarifying it to the others.

		  They continued that path, keeping parallel with the storm clouds that continued to hang over the mountain peaks and never seemed to end.



-The Morning of the Third Day-



		  "I think I can see Gaoling," Aang said, trying to be helpful. "We're nearly there."

		  Katara turned to see if she could also see the city, and indeed, she could make out some sort of settlement on the horizon. The waterbender frowned. "I can see it, too, but what's that down there? That… cloud of dust?"

		  Aang shrugged. "Since it's too wide to go around, I figure if we keep high enough we won't have to worry about whatever it is. We should reach the city soon."

		  As Appa began to pass over the dust cloud, just making it past the boundaries, Toph's keen ears caught a sound. "Wait, stop. Go back." Her eyes widened slightly. "Aang, turn Appa around."

		  Aang seemed uneasy. "He thinks we should turn back, too. Okay, buddy…" Momo chirruped uncertainly, standing from where he was laying in Katara's lap and moving about nervously. As Appa made to turn, something appeared at the corner of Aang's vision – red…

		  "Get us out of here!"

		  No one knew who said it, for the voice was indistinguishable among the sear of fireballs erupting from the dust cloud. Aang had been sure that they were flying high enough; certainly they were at an elevation beyond what any firebender would be able to launch an attack. As they began to retreat, the dust started to settle – and Aang turned back to see the benders and noticed that they were all standing on tall columns, so they hadn't been shooting from the ground.

		  Suddenly the columns pitched forward; the firebenders began to earthbend forward, reminding Sokka and Aang of how Toph had used earthbending as means of travel when they picked her up on their way back to Ba Sing Se. Toph herself could hear them loud and clear – and easily recognized that they were skilled from the mere sounds of their bending.

		  There were definitely too many of them to fight – a line of them stretched out along the horizon, though not to the very edge of it. Perhaps there were five-hundred, perhaps a thousand – the number couldn't be estimated. If they truly were masters of all the elements, they were a force to be reckoned with, most certainly. They accelerated at stunning speeds, catching up with the air bison.

		  Katara inhaled deeply. "They're airbenders, Aang," she murmured, lightly touching his shoulder. "It doesn't matter how high we go, because they're able to do it, too." The Shinsei never seemed to stop accelerating – they were blurs, and there was a steady, earthy hum as they pursued the Avatar and his companions.

		  "They don't have gliders, Aang said in reply, though his voice audibly shook with his lack of confidence in this statement's truth.

		  Katara simply shook her head. "We don't know that. We don't know what they're capable of. Running, that'll get us nowhere." She strained her voice so that the others passengers could hear her. Sokka perked to her words.

		  "He won't kill us yet. He's… testing us, I bet," he offered, peering over Appa's saddle with a scrutinizing expression. "Maybe he's trying to scare us. Maybe he wants us to fight. I don't know, but I'm pretty sure that whatever his plans are, he's put more thought into it than just killing us outright."

		  "Does he want to capture us, then?" Zuko asked. As the conversation continued, Appa continued to climb higher; his sloping ascent began to level, and the Shinsei continued pursuit. Despite Appa's speed and the assistance of air travel, they were almost directly below the Avatar, preparing for whatever Kanaye had in mind.

		  Sokka's frown defined considerably; he never took his eyes off the figures below them. "Maybe. Maybe that is what he's doing." The warrior shook his head, wondering at the enemy's plans. "We shouldn't just wait around and let him strike first, though. That might work for Toph, but we have to get the edge on this fight quick – I feel like we're doing just what he wants."

		  Aang turned to him and nodded solemnly. "We'll stand and fight," he said simply, and the others silently agreed. He encouraged Appa to turn as quickly as he could so that he might get behind the Shinsei to land – that way the Shinsei wouldn't stand between the Avatar's group and Gaoling.

		  Appa turned abruptly and the Shinsei, obviously at least a little surprised by this, began to turn around as well. They worked in one synchronized motion to accomplish a sweeping turn for the purpose of keeping their momentum. Appa was flying very fast, but he began to slow as he prepared to land; they were far enough away from the Shinsei to get off of Appa and prepare for the fight ahead. It was obvious that they wouldn't be allowed any sort of rest until the Shinsei had accomplished whatever it was that they wanted, and so, because Appa's speed was no match for the powerful speed of their bending, and because using the shelter of Gaoling (if they could make it there) would only endanger the citizens, fighting was the only other option. Well, there was giving up – but since when did the Avatar and his companions ever resort to that?

Appa's feet touched the ground; Aang airbended himself and Katara off, and Toph, Sokka, and Zuko joined them moments later. Each prepared in his or her own way – Aang steadied himself, Katara drew water from the container at her side, Zuko loosened himself up and allowed flames to dance in his hands, Sokka drew his sword, and Toph – Toph's toes flexed, measuring their approaching adversaries; her muscles tensed, waiting, just waiting for one of them to make the first move. She would counter – and she, fueled by a flame more common in short-tempered firebenders, was more than ready to exchange her anger for the adrenaline-pumping thrill of battle. She needed to fight.

		  In the blink of an eye, the Shinsei were upon them; such a straightforward attack shook the others' steadiness, but Toph's fighting was so perfectly composed in the very beginning that it seemed the fight between she and her opponents had been rehearsed.

		  Toph held the heels of her hands together and thrust forward boulder; in the time it took her to perform that single movement a thread of flames, flurry of earthen daggers, and gust of strong wind came at her from three different opponents. To stay focused in battle they could only bend one element at a time – Toph resolved that their speed during their pursuit had only been a combination of airbending and earthbending because they hadn't really had to focus on their actions. She had little time to think, though, before she was forced to make a wooden shield burst from the ground to deflect a fire blast.

		  The only water around belonged to Katara, so the Shinsei were unable to waterbend. This small comfort was barely worth it, but at least Katara's bending was unique; Zuko, too, had a small advantage since there was no water to put out his flames, though earthbending was still against his particular element. The Shinsei, to everyone's surprise, had no armor – at least none that they could see (or feel through vibrations), and this was slightly comforting, too.

		  Toph noticed that only a small number had engaged in combat – fifteen fought against them, and the others kept a respective distance. This was a curious thing to Toph, but she knew that if every one of them had been fighting them, they wouldn't have had a prayer – whether death was Kanaye's intention or not, that was undoubtedly what would have happened. It would have been inescapable.

		  Toph quickly resolved that Kanaye wanted them to live, and, with this relief engulfing her, her motions were more fluid. Fighting three people was difficult, but whatever happened, they would all, most likely (for she was never sure of anything), make it out alive. Then she could go to Gaoling and see if Kanaye had spared them, killed them, or captured them – she wouldn't be able to save them, not yet.

		  She made the ground beneath the one currently earthbending tremble and slide uncertainly. He would have done the same to her, but she had utter and complete control of the earth around her – none of them could turn her native element against her, no matter how hard they tried. They could throw rocks at her all they wanted, but their mastery of the earth was no greater than hers; because, too, they weren't capable of their own wills and couldn't have faults or feel emotions, they couldn't feel a connection with that element. Earth was not special to them – it was a skill, and that was all. That was why she could so easily throw the earth out from under each of them but they had no hope of taking away her power of her element.

		  She could feel the strength of the earth resonating beneath her and flowing into her, through her. She knew at once that they could feel no such thing – they might be masters in one sense of the word, but they would never understand any of the four elements, and for a brief moment Toph felt sorry for them.

		  Then her mind returned to the fight at hand.

		  Each of her opponents was an equal distance away from her and from each other. She was in the center of them, and decided to use this to her advantage. While they each sent a blast of fire at her at once, she encased herself in a strong, sturdy rock shell shaped like a triangular pyramid. When she first felt the pressure of the benders' blasts against her shell, she used as much strength as she could muster to send three slabs of rock that composed her casing flying at the Shinsei. The slabs were so strong that instead of shattering against the blast of the fire, they bore the flames backward, and her Shinsei opponents were both burned and beaten by her attack.

		  The first composed himself quickly and sent a whirlwind at her; she sent earthen discs at it for the purpose of slowing it down and weakening its power, and as the remaining light, airy breeze passed over her, she stomped the ground and sent a slanted pillar at the second recovering Shinsei, hurling the woman back. The third used this moment to attack her from behind and punched a succession of fireballs at her. She took the first one, but the others were extinguished by a boulder the ground choked up for her. She sent it flying at the man, and his attacks were futile as the rock hit him square in the chest. He fell, dazed and perhaps mortally wounded, though that depended on the hit.

		  The second was still winded, and that just left Toph with the first. While he was at the same skill level as the other two, he was much faster – and therefore much more of a challenge. She evaded or countered his attacks, and she had yet to throw a blow herself; she was trying to wear him out, but his breathing was always steady. It seemed as though she Shinsei had a never-ending supply of energy.

		  Aang still had all three of his opponents, but he was matched equally with all of them, and he felt a connection with each of the elements he worked with. Because they had no such connection, he was doing very well. He wasn't powered by anger, as Toph had been, but by a steadily growing flame that gave him the ability to do nothing more than grow and do better – the Shinsei could do no such thing, and had no particular strategy. If ever they seemed to have forethought their attacks, it was just luck on their part.

		  Katara was fighting two. One had intended to rob her of her water, but she quickly got rid of him; just as the Shinsei had not been able to make Toph relinquish her power over the earth beneath her, so were the Shinsei not able to rob Katara of the part of her element over which she had control. Katara handled her water with unmatched grace and elegance which the Shinsei seemed to have none of; Katara had many advantages.

		  Zuko found power for his attacks in his passion for his country and its safety; these monsters would act to control the Fire Nation, and then the world – and they had no right to any of it, least of all what he and the Avatar had earned. These creatures were thoughtless, careless – they were nothing, and if there could be something more despicably valueless, they would have been such. These unnatural evils had no right to anything. How dare Kanaye use these things to bring himself into power? How dare he? Zuko's passion flowed from his body to the fire that sprang from his fingertips and palms. His motions were precise – he fought with as much strength as he could find. He was hindered by nothing and no one. He had one man left to defeat, and he intended to do so.

		  Sokka, well – if anyone besides Toph had been more than semi-conscious of Sokka's accomplishments, they would have been pleasantly surprised. Sokka was perhaps the most skilled non-bender, it was true; his weapon prowess was unmatched. He sometimes found it difficult to fight benders because they could attack from good distances, out of reach of Sokka's sword, but even then he fought well. This time, though, he had been presented with three benders, and each a master of all four elements. This was sure to have been one of the most challenging fights he had ever engaged in; yet, despite the horribly unfavorable odds, he was constantly completely aware of the stakes – and he fought brilliantly. While the black sword he bore did not have the ability to strike fear in the hearts of his opponents, as it would have if his adversaries had been capable of emotion, he was nonetheless outstanding in battle. He was quick and easily dodged almost every attack the Shinsei could throw at him – and he didn't hesitate to put his weapon to use every time the Shinsei came close. Even after mortally wounding one (the man suffered a horrifying blow to his arm and was barely alive because of blood loss), the other two had no fear of the black sword and its bearer. Sokka pierced a second bender in his chest; he was not unused to such brutality, but he would never really feel accustomed to it. He could murder a countless number of people and his heart would always pound with the knowledge of his actions, the pure, basic reality of what he'd done. He was horrified at himself, but all the same, when he fought the enemy there was always a thrill in it, too.

		  Sokka's third adversary was a woman. Once upon a time he might have refused to fight her; but he had grown into the habit of turning aside the knowledge of gender to embrace the knowledge of the enemy's identity. Being a female had absolutely nothing to do with how evil a person's intentions were, as Azula so skillfully proved, and so Sokka had no problem fighting her, though maybe, a long time ago, he very well would have.

		  Toph was making little progress. The man she faced was much faster than her; he expertly manipulated his elements. Toph's insides burned at that word – manipulate. It was a horrible, disgusting word to describe the handling of one's element, but that was exactly what he was doing. He was making his lack of a bond with the earth, with fire, with air so painfully obvious that Toph felt another kind of rage, one that felt purer and more natural. How could this man be called a bender? He didn't bend. He manipulated. He didn't deserve to have any kind of control over an element. He did not appreciate. He did not love, did not live for the elements that he had mastered. Mastered! To be called a master was a privilege and an honor. He had no right to it, no matter how well he could manipulate.

		  The connection between Toph and her element had been there from before birth; it was woven intricately and could never be broken. It would always be there, and Toph hated – purely hated – how someone like him had the audacity (though he had no audacity) to call himself a master. How sickening! She searched in vain for any way that he might use to establish that indeed there was a connection; but while he moved with utter certainty, he did not move like an earthbender. While his motions were fluid, they did not have the honorable semblance to those of a waterbender. While his attacks were precise, they were not remotely reminiscent of those a firebender might perform; while he himself was light and loose and he executed his hits so naturally and easily, he could never, ever be considered an airbender. He was merely an imitation of each of these things. He was a sick, filthy imitation – he was nothing real. He was not a person, but a lowly being not even worthy of a name.

		  This hate consumed Toph, and her attacks became unbearably powerful. Her final adversary fought on, unheeded at first, but finally his bruised, battered body was swallowed by a chasm, and the earth choked him down; his empty eyes would never again be graced with sunlight, but with darkness until life drained from him body. Toph found sick satisfaction in that and quickly helped the others vanquish their opponents; the Shinsei that had not been pitched into battle at the beginning still kept their distance, not looking at the battle because their eyes had no interest.

		  Soon enough the Avatar's companions were victorious, in a bittersweet way. Their test was over. They had survived – they were bruised, beaten, bleeding, battered, broken in several places, but most of all they were gloriously alive, and that was all that truly mattered. They were alive and they had identities, they had emotions and faults. They had their elements, and that was all they would ever need.

		  Their ears rang, though the sounds of battle had faded some time ago. The area around them was horrifying – the ground was practically ripped apart in some places, and whatever grass might have been there before was long gone now. Silence reigned for a few beautiful moments.

		  The Shinsei, in one swift movement, all turned away from the Avatar and companions and began to earthbend away, leaving a conspicuous path behind them. One man, however, blew a gust of air at them, and as he turned to leave, a folded piece of parchment landed on the ground at their feet. Toph felt the tiny vibrations as it landed and felt uneasy; the others did, too. Since no one else seemed too keen to pick it up, Sokka bent and took the parchment between his thumb and forefinger. He unfolded it and began to read what it said; the more he spoke, the lower his voice got. His voice was dangerously grave as he spoke the last word, the signature.

		  Youths,

		  You have impressed me with your talented fighting. It was my first time seeing the Shinsei in a real battle, and allow me to say that now that I am aware of their power, I am better equipped for the events that are to follow. Hopefully you will learn of these events soon enough. Hopefully by now you're aware that if you barely succeeded against the Shinsei on this day, you have yet to experience the true strength of the entire army. I merely wished to see your talents and the skill of the Shinsei, and I suppose I did you a favor in showing you exactly what you're against.

		  I was especially pleased to be able to finally see the greatest earthbender in the world fight my benders. I have great plans for you, Toph. I suppose at this time you are wondering about your parents – I am more than happy to oblige. I shall not tell you of their fates just yet. You will learn soon enough.

		  Phase two of Toph's destruction is on the horizon. Keep it in mind.

		  Yours,

Kanaye



-



End



-



And here is the output:
Welcome to the Pod Book program.
By default, this program will search in /home/test/Documents.
The file(s) will be saved in /home/test/Documents.

Enter a file to convert.
text.txt
--



Chapter 6: What's in a Master?



---



		  A few evenings after leaving Kutan, Sokka busied himself over some maps. "Okay, so Bumi told us… he said it was this island," Sokka said, pointing to one of the islands of the Southern Air Temple.

		  Aang stood from Appa's head and hopped weightlessly into the saddle. Then he leaned over Sokka's shoulder and identified, "That's Whale Tail Island. See the shape?"

		  "You know it?" Zuko asked, curious and slightly surprised.

		  "Sure," Aang replied, smiling at some distant memory. "We – the monks and some of the other kids – went there sometimes. There was a temple there… a big one, and no one ever went inside. And since temples were pretty common, no one thought to ask about it." Aang shrugged. "Could be the place Kanaye's going for. I've never been inside of it, so I don't know what its like."

		  Katara nodded steadily, taking in the information. Sokka made no move to say that he'd heard the Avatar; he was studying the map, and every now and then he would glance up at the sky. He sighed, preparing to deliver news. "The only way we'll be able to get to Gaoling before the Shinsei is if we go through the mountains."

		  Katara looked toward the triangular shapes on the horizon. If they continued in that direction, they were sure to face turbulence; the sky was colored a deep, ugly purple, reminiscent of a bruise. "That'll bring us through bad weather. Are you sure the mountains won't be too dangerous? Is there a safer way?"

		  "We could go around them, but that would make us at least three days late. We just can't afford it." Sokka shook his head; Toph stayed silent, as she had been all day. He worried about her but directed his face to Katara, waiting for her response.

		  Katara said nothing, knowing that despite the dangers of the mountains, worse things would lurk on the other side. She licked her lips and nodded, hoping that the Spirits would keep them out of harm's way.

		  Hours passed, and they did so in silence; Katara had busied herself with repairing a few tears in the sleeping bags, Zuko was sitting as far away from them as possible and doing nothing, Aang was driving and offered the occasional nervous remark in regard to the weather, Sokka switched between scrutinizing the maps and pretending to read some scrolls, and Toph did nothing and said nothing. From time to time her hand would drift to her arm and she would touch the meteorite bracelet, but other than that, she was still.

		  Eventually Sokka had to stop pretending. He'd read one sentence eighteen times and he still didn't know what it said; his mind was elsewhere. Toph was unsettled, and even if it wasn't really any of his business (but since when did that matter?), he wanted to be helpful. After putting his scrolls aside he scooted beside her.

		  Her expression changed from thoughtful and slightly sad to slightly puzzled, but she did not otherwise acknowledge him. This was fine with him; he was content to sit in silence, but he thought to offer a few comforting words first. "They'll be ok-"

		  Quite suddenly a crack of lightning split the sky, and a mere moment later thunder ripped it apart. Sokka glanced at Toph for a moment and then sprang to his feet, hoping to help Aang keep direction.

		  Toph was unnerved; she held her fright well, but afraid she was. She hated storms anyway (loved the rain, but hated thunder and lightening), and she was vulnerable in the air. It was unknown territory. She felt safe on Appa, but that security was shattered by lightening and scattered by the roar of thunder. Toph very rarely felt small – but storms had that effect on her, and it wasn't easily accepted.

		  Another thing that contributed to her particular dislike of storms in the air was the fact that sometimes even Appa was frightened by them. He was more accustomed to it, and p



I hope this is what you are looking for! :)
Was This Post Helpful? 0
  • +
  • -

#5 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Re: Character encoding in output

Posted 04 March 2008 - 06:56 AM

I feel so weird posting fanfiction but it was the only thing that I had and it's what I was using. I had saved it as a text file so I don't know what's wrong. I just did it with another file, the Hacker's Manifesto, and saved it as .txt. I'm having a problem with this one as well. However, it looks like it's skipping every other letter. Guess I just programmed it wrong.
Was This Post Helpful? 0
  • +
  • -

#6 letthecolorsrumble  Icon User is offline

  • Student of The Sun
  • member icon

Reputation: 27
  • View blog
  • Posts: 555
  • Joined: 07-November 07

Re: Character encoding in output

Posted 04 March 2008 - 07:05 AM

So is there a question in there? If you've checked the output, you should know that it worked fine with me. If you still having troubles, just ask for help. :)
Was This Post Helpful? 0
  • +
  • -

#7 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Re: Character encoding in output

Posted 05 March 2008 - 02:55 PM

Thanks man! It works! I'm not quite sure was was wrong though. Could you explain it? Also, you took out some stuff that I wanted left in there but don't worry, I added it. Now I can go about my business and finish this baby.

Last, a senior at my school suggested that I use RandomAccessFile instead of bufferedreader and bufferedwriter, especially if I go into the IB program (hoping I can). Are there benefits of using that method?

Edit:
Another question. Why does it give me an error if the file isn't found? I wanted it to instead display "File not found" or something like that.

This post has been edited by Techno Mage: 05 March 2008 - 02:57 PM

Was This Post Helpful? 0
  • +
  • -

#8 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Re: Character encoding in output

Posted 07 March 2008 - 03:46 PM

One last thing. It's not writing to a file but it does create one. Here's the part.
if(text.exists())  
		{
			int i = 0; 
			int j = 1;
			int count = 0;
			while (count!=text.length())
			{
				//Creates a new file and numbers it.
				writer = new BufferedWriter(new FileWriter("/home/test/Documents/"+"part_"+j+".txt"));
				//writer = new BufferedWriter(new FileWriter("E:\\"+"part_"+j+".txt"));
				while  ( i < 4000-1 )  
				{
					buffer[i] = (char)reader.read();  
					i++;  
					count++;
				}
				i = 0;
				System.out.println(buffer);
				writer.write(buffer);		
			}
		}


Was This Post Helpful? 0
  • +
  • -

#9 Techno Mage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 86
  • Joined: 10-June 07

Re: Character encoding in output

Posted 19 March 2008 - 02:17 PM

I'm having a problem with the encoding. Before, the problem that I was having wasn't with character encoding, it was skipping every other letter.
NOW, I'm having an encoding problem. There's a pic of the encoding problem. The thing that bothers me is that that last line goes on for a long time even with text wrapping on.

Attached Image
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1