Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Exp7 SPCC 27

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Experiment No.

Name:Sawali Morajkar

Roll no:27

//Program:

sub.txt file

void main

a=10+b*c;

x=b*c+5;

SubExp.java file

import java.io.*;

public class SubExp

public static void main(String args[]) throws IOException

Sub r =new Sub();

r.sub();

class Sub

void sub() throws IOException

{
File file=new File("sub.txt");

BufferedReader br=new BufferedReader(new FileReader(file));

String read=new String();

StringBuffer sb=new StringBuffer();

System.out.println("\n input content--");

while((read=br.readLine())!=null)

System.out.println(read);

sb.append(read+"\n");

System.out.println("\n\n output--");

System.out.println("temp=b*c;");

int x=sb.indexOf("{");

int y=sb.indexOf("}");

sb.replace(x+1, x+y, "a=10 + temp\n x=temp+5 }");

System.out.println(sb.toString());

}
Output:

You might also like