user3732947 user3732947 - 2 months ago 9
Java Question

How to turn my multiple-line java code into one line of code?

I am wondering if it is possible to turn my multiple line source code into one line. Basically to make it harder for other people to read. Is there a tool or a script that is designed to do that?
If not, what is the easiest way to do it?

This is my example code:

public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello, world");
}
}


This is the end result i want:

public class Hello { public static void main(String[] args) { System.out.println("Hello, world"); } }


PS. please don't go harsh on me, and give me criticism in a comment before downvoting.I'm a new programmer and my account is about to be terminated, because my questions were downvoted a lot. Why are people so harsh and aggressive on StackOverFlow? We aren't all "professionals" here. Some of us are just beginners in this field, and don't know a lot of things.
Thanks.

Answer

I think you can just remove all line breaks, which in Windows is the sequence \r\n. Try the following replacement in Notepad++:

enter image description here

Find:

\s*\r\n\s*

Replace:

(a single space)

Make sure you do the find/replacement in regex mode.