[Java for Android App Development] shanalikhan:
Hi ,

I am developing an app which send files direcctory of PC to android. first PC send the drives names and android app reads it via bufferedreader

then upon selecting any drives although the PC send the folders of that drives but android bufferedreader doesnt work to work. but it stucks on there.

Code stucks on the bold lines.... below

Following is the code. please help

////

It is sending drives

String st;
System.out.println("CLIENT - Starting");
st = ser.BufferedReader().readLine();
System.out.println(st);
if(st.equals("READPC")){
System.out.println(st);
ser.BufferedWriter().write("OK");
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();
File[] fi = File.listRoots();
//System.out.println("senting roots");
//ArrayList<String> arr = new ArrayList<>();
for(int i=0;i<fi.length;i++){
//.add(fi[i].getPath());
ser.BufferedWriter().write(fi[i].getPath());
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();
//System.out.println(fi[i].getPath());
}
//ser.ObjectOutputStream().writeObject(arr);
ser.BufferedWriter().write("END");
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();
//System.out.println("sent");

HandleCommands();

}

///It is sending directories.

public void HandleCommands() throws Exception{

System.out.println("CLIENT - Sending Files");
tmp = ser.BufferedReader().readLine();
System.out.println(tmp);
if(tmp.equals("LISTFILES")){
String path = ser.BufferedReader().readLine();
//ser.PrintWriter().println("OK");
//ser.PrintWriter().flush();
System.out.println("CLIENT - path"+ path);
File[] fl = new File(path).listFiles();
for(int i=0;i<fl.length;i++){
if(!fl[i].isHidden()){
if(fl[i].isDirectory())
{
ser.BufferedWriter().write(fl[i].getPath());
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();

System.out.println("Folder");
}
else if(fl[i].isFile()){

ser.BufferedWriter().write(fl[i].getPath());
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();
System.out.println("File");
}
//Thread.sleep(200);

System.out.println(fl[i].getPath());
}

}

}
ser.BufferedWriter().write("END");
ser.BufferedWriter().write("\n");
ser.BufferedWriter().flush();
System.out.println("End");

}

while following is the code to read the files. from pc ( android )

cli.OutputStream().write("READPC".getBytes());
cli.OutputStream().write("\n".getBytes());
cli.OutputStream().flush();
//Log.e("TINTERACT-STAT", "written");
String stat = cli.BufferedReader().readLine();
//Log.e("TINTERACT-STAT", stat);
drive = new ArrayList<String>();
fileType = new ArrayList<String>();
fileNames = new ArrayList<String>();
if(stat.equals("OK"))
{

//drive = (ArrayList<String>)cli.ObjectInputStream().readObject();
//while(!(stat = cli.BufferedReader().readLine()).equals("END"))
while((stat = cli.BufferedReader().readLine())!=null)
{
if(!stat.equals("END"))
{
drive.add(stat);
fileType.add("Folder");
}

//Log.e("TINTERACT", stat);
}

Log.d("TINTERACT", "drives got:"+ drive.size());

}

public void ListFiles(String path, String type){
try{
working= true;

Log.d("TINTERACT", "Listing path getting");
cli.OutputStream().write("LISTFILES".getBytes());
cli.OutputStream().write("\n".getBytes());
cli.OutputStream().flush();
//Log.e("TINTERACT","Type:"+ type);
if(type.equals("Folder")){
cli.OutputStream().write(path.getBytes());
cli.OutputStream().write("\n".getBytes());
cli.OutputStream().flush();
//Log.d("TINTERACT", "reading"+cli.BufferedReader().readLine());
String line=null;
Log.d("TINTERACT", "Start Getting files names");
if(cli.BufferedReader().ready()){

[B]	Log.d("TINTERACT", "reading"+ cli.BufferedReader().readLine());
/*
while((line=cli.BufferedReader().readLine())!=null)
{
//fileNames.add(line);
Log.d("TINTERACT", "reading"+ line);
}
*/[/B]

}

} else if(type.equals("File")){

}
}
catch(Exception ex){
String a ="a"+ ex.getMessage();
Log.e("TINTERACT", "ERROR - "+a);
}
}