/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package p1;
import java.io.BufferedReader;
import java.io.File;
import java.io.*;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
/**
*
* @author sujith
*/
public class str3 {
public static void main(String[] args){
File file= new File("C:\\data3.txt");
File file2=new File("C:\\data3.txt");
// String[] tokens = null;
int k=0;
try{
//BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
// BufferedReader br= new BufferedReader(new FileReader(f));
BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
FileInputStream in= new FileInputStream("C:\\data3.txt");
FileOutputStream op= new FileOutputStream("E:\\data5.txt");
//InputStreamReader ip=new InputStreamReader(in);
//OutputStreamWriter op= new OutputStreamWriter(new FileOutputStream("E:\\data4.txt"));
//BufferedReader br= new BufferedReader(in);
// System.out.println(ip);
while((k=in.read())!=-1){
System.out.println((char)k);
// op.write(k);
// op.append((char)k);
// System.out.println((byte)k);
}
String line=null;
int count=0;
int i=0;
while((line=br.readLine())!=null){
//tokens=line.split("\\s+");
StringTokenizer st= new StringTokenizer(line," ");
while(st.hasMoreTokens()){
String s=st.nextToken();
char c;
StringBuffer sb=new StringBuffer(s);
for(int j=0;j<sb.length();j++){
for(int m=j+1;m<sb.length();m++){
// System.out.println(sb.ch);
//sb.setCharAt(i, ch);
if(sb.charAt(j)>sb.charAt(m)){
c=sb.charAt(j);
sb.setCharAt(j,sb.charAt(m));
sb.setCharAt(m, c);
}
}
}
System.out.println(sb);
//System.out.println(st.nextToken());
//StringBuffer sb=new StringBuffer(st.nextToken());
// StringBuilder sb= new StringBuilder(st.nextToken());
//String sb=st.nextToken();
// String[] sb=new String[]{st.nextToken()};
//System.out.println(sb.length);
// System.out.println(st.nextToken());
// op.write(st.nextToken().getBytes());
// op.write(" ".getBytes());
//System.out.println(st.nextToken().getClass().getName());
op.write(sb.toString().getBytes());
op.write(" ".getBytes());
}
op.write("\n".getBytes());
}
}catch(Exception e){
System.out.println(e);
}
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package p1;
import java.io.BufferedReader;
import java.io.File;
import java.io.*;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.*;
/**
*
* @author sujith
*/
public class str3 {
public static void main(String[] args){
File file= new File("C:\\data3.txt");
File file2=new File("C:\\data3.txt");
// String[] tokens = null;
int k=0;
try{
//BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
// BufferedReader br= new BufferedReader(new FileReader(f));
BufferedReader br= new BufferedReader(new InputStreamReader(new FileInputStream(file)));
FileInputStream in= new FileInputStream("C:\\data3.txt");
FileOutputStream op= new FileOutputStream("E:\\data5.txt");
//InputStreamReader ip=new InputStreamReader(in);
//OutputStreamWriter op= new OutputStreamWriter(new FileOutputStream("E:\\data4.txt"));
//BufferedReader br= new BufferedReader(in);
// System.out.println(ip);
while((k=in.read())!=-1){
System.out.println((char)k);
// op.write(k);
// op.append((char)k);
// System.out.println((byte)k);
}
String line=null;
int count=0;
int i=0;
while((line=br.readLine())!=null){
//tokens=line.split("\\s+");
StringTokenizer st= new StringTokenizer(line," ");
while(st.hasMoreTokens()){
String s=st.nextToken();
char c;
StringBuffer sb=new StringBuffer(s);
for(int j=0;j<sb.length();j++){
for(int m=j+1;m<sb.length();m++){
// System.out.println(sb.ch);
//sb.setCharAt(i, ch);
if(sb.charAt(j)>sb.charAt(m)){
c=sb.charAt(j);
sb.setCharAt(j,sb.charAt(m));
sb.setCharAt(m, c);
}
}
}
System.out.println(sb);
//System.out.println(st.nextToken());
//StringBuffer sb=new StringBuffer(st.nextToken());
// StringBuilder sb= new StringBuilder(st.nextToken());
//String sb=st.nextToken();
// String[] sb=new String[]{st.nextToken()};
//System.out.println(sb.length);
// System.out.println(st.nextToken());
// op.write(st.nextToken().getBytes());
// op.write(" ".getBytes());
//System.out.println(st.nextToken().getClass().getName());
op.write(sb.toString().getBytes());
op.write(" ".getBytes());
}
op.write("\n".getBytes());
}
}catch(Exception e){
System.out.println(e);
}
}
}
No comments:
Post a Comment