How do I customize string formatting rules in Eclipse?

I don't remember what it is called as I am new to java, but I want to know where to find this in the Eclipse formatter. In my getBookData method, I want the stuff after the comma to not start a new line.

package input;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class ReadFile {

    public static Object[] currentBookData;

    public static void getBookData() throws IOException {
        try (Stream<String> stream = Files.lines(Paths.get("C:/test.txt"), Charset.defaultCharset())) { // I want the stuff after the comma to be on the same line.
            currentBookData = stream.toArray();
        } 

        catch (IOException ex) {
            System.out.println(ex.getMessage());
        }

    }
}

      

+3


source to share


1 answer


Move:

"Window -> Preferences -> Java ->Code Style -> Formatter".

      

Adjust the existing template or create / import a new one and use the same.



To change the maximum line width, select a profile and then follow these steps:

"Edit -> Line Wrapping" 

      

and set the desired character length in the "Max line width" field, for example. "one hundred".

+1


source







All Articles